Sketchy/js/main.js

33 lines
748 B
JavaScript
Raw Normal View History

2014-02-01 18:18:29 +00:00
"use strict";
$(document).ready(function() {
window.c = $('canvas')[0].getContext('2d');
window.settings = {
lineWidth : 5,
strokeStyle : 'black',
type: 'sketch',
lineCap: 'round',
lineJoin: 'round'
};
window.points = [];
window.$c = $('canvas');
sizeAndPos();
$(window).resize(sizeAndPos);
2014-02-02 09:48:10 +00:00
$c.bind('mousedown touchstart', function(e) {
2014-02-02 09:50:20 +00:00
alert(e.pageX);
2014-02-01 18:18:29 +00:00
var xy = relative(e.pageX, e.pageY);
startPoint(xy.x, xy.y);
window.active = true;
2014-02-02 09:48:10 +00:00
}).bind('mousemove touchmove', function(e) {
2014-02-01 18:18:29 +00:00
if (!window.active || settings.type == 'line') return;
var xy = relative(e.pageX, e.pageY);
drawPoint(xy.x, xy.y);
2014-02-02 09:48:10 +00:00
}).bind('mouseup touchend', function() {
2014-02-01 18:18:29 +00:00
window.active = false;
})
})