Skip to content
This repository
Browse code

probable fix for mobile spectrometer code

  • Loading branch information...
commit 924362c5b3f0723137fd8a1296796ae050210fd7 1 parent 431adf8
Jeffrey Warren authored August 06, 2012

Showing 1 changed file with 8 additions and 6 deletions. Show diff stats Hide diff stats

  1. 14  webserver/public/javascripts/capture.js
14  webserver/public/javascripts/capture.js
@@ -108,7 +108,6 @@ $W = {
108 108
 		
109 109
 		var sample_height = 10 // how many pixels to sample
110 110
 		if ($W.pos >= 4 * w * sample_height) { 
111  
-			console.log('putting image')
112 111
 			$W.canvas.getContext('2d').putImageData(img, 0, 0);
113 112
 			$W.ctx.drawImage(img, 0, 0);
114 113
 			$W.pos = 0;
@@ -122,7 +121,13 @@ $W = {
122 121
 		if ($W.options.context === 'webrtc') {
123 122
 			var video = document.getElementsByTagName('video')[0]; 
124 123
 			var startrow = $W.sample_start_row//parseInt($W.options.height/2)
  124
+			$W.ctx.save()
  125
+			if ($W.mobile) {
  126
+				$W.ctx.rotate(Math.PI/2)
  127
+				//$W.ctx.translate(32, 120);
  128
+			}
125 129
 			$W.ctx.drawImage(video, 0, -startrow);
  130
+			$W.ctx.restore()
126 131
 		} else if($W.options.context === 'flash'){
127 132
 			window.webcam.capture();
128 133
 		} else {
@@ -130,11 +135,7 @@ $W = {
130 135
 		}
131 136
 		//img = $W.image
132 137
 		var sample_height = $W.sample_end_row - $W.sample_start_row // how many pixels to sample
133  
-		if ($W.mobile) {
134  
-			img = $W.ctx.getImageData(0,0,sample_height,$W.canvas.height)
135  
-		} else {
136  
-			img = $W.ctx.getImageData(0,0,$W.canvas.width,sample_height)
137  
-		}
  138
+		img = $W.ctx.getImageData(0,0,$W.canvas.width,sample_height)
138 139
 		$W.data = [{label: "webcam",data:[]}]
139 140
 		$W.full_data = []
140 141
 		var data = ''
@@ -163,6 +164,7 @@ $W = {
163 164
 			else $W.data[0].data.push([parseInt($W.getWavelength(col)),intensity/2.55])
164 165
 		}
165 166
 		plot = $.plot($("#graph"),$W.data,flotoptions);
  167
+
166 168
 	},
167 169
 	geolocate: function() {
168 170
 		if (navigator.geolocation) {

0 notes on commit 924362c

Please sign in to comment.
Something went wrong with that request. Please try again.