Permalink
Browse files

Fixed canvas drawing error

  • Loading branch information...
1 parent d16e787 commit a210ee44ea4cbf83689e3f4ec6d350d3f0bb104d Roger Chapman committed Aug 22, 2011
View
@@ -5,4 +5,4 @@ build
xcuserdata
*.xcworkspace
.project
-
+*.swp
View
Binary file not shown.
View
@@ -3,6 +3,9 @@
* Module dependencies.
*/
+// Cloud app fix.
+require.paths.unshift('./node_modules');
+
var express = require('express'),
socketio = require('socket.io');
@@ -47,7 +50,7 @@ app.get('/', function(req, res){
}
});
-app.listen(3000);
+app.listen(process.env.VMC_APP_PORT || 3000);
console.log("Server listening on port %d in %s mode", app.address().port, app.settings.env);
// private methods
@@ -25,8 +25,6 @@ h2 {
}
canvas {
- width:600px;
- height: 600px;
border: 1px solid black;
display: block;
margin-left: auto;
@@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <title>Node Drawing</title>
+ <title>rogchap's oode Drawing</title>
<meta name="author" content="Roger Chapman" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js "></script>
<script src="/socket.io/socket.io.js"></script>
@@ -11,6 +11,7 @@
$(function(){
var socket = io.connect(location.host + "/desktop");
var codeNumber = $('#codenumber');
+ var clearBtn = $('#clearBtn');
var infoText = $('#infoText');
var canvas = document.getElementById('sketchpad');
@@ -20,12 +21,13 @@
isDrawing: false,
touchstart: function(coors){
context.beginPath();
- context.moveTo(coors.x, coors.y);
+ context.moveTo(coors.x*2, coors.y*2);
this.isDrawing = true;
},
touchmove: function(coors){
if (this.isDrawing) {
- context.lineTo(coors.x, coors.y);
+ context.lineTo(coors.x*2, coors.y*2);
+ context.lineWidth = 3;
context.stroke();
}
},
@@ -36,6 +38,10 @@
}
}
};
+
+ clearBtn.click(function(){
+ context.clearRect(0,0,320,440);
+ });
socket.on('code', function(data){
codeNumber.text(data);
@@ -56,12 +62,13 @@
<div class="container">
<div class="canvaswrapper">
<div class="innerwrapper">
- <h2>Welcome to Node Drawing</h2>
+ <h2>Welcome to rogchap's Node Drawing</h2>
<div id="infoText">
Visit this site on your mobile (iPhone &amp; Android) and enter code:
<span id="codenumber">0000</span>
</div>
- <canvas id="sketchpad"></canvas>
+ <canvas id="sketchpad" width="320px" height="440px"></canvas>
+ <input type="button" id="clearBtn" value="clear"/>
</div>
</div>
</div>
@@ -4,7 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
- <title>Node Drawing</title>
+ <title>rogchap's Node Drawing</title>
<meta name="author" content="Roger Chapman" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js "></script>
<script src="/socket.io/socket.io.js"></script>
@@ -65,4 +65,4 @@
<input id="codeInput" type="number" /><input type="button" id="enterCode" value="Enter" />
</div>
</body>
-</html>
+</html>

0 comments on commit a210ee4

Please sign in to comment.