Sketchy/Mobile/js/main.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-02-01 18:18:29 +00:00
"use strict";
$(document).ready(function() {
2014-02-02 20:16:28 +00:00
window.c = $('canvas')[0].getContext('2d');
window.o = $('canvas')[1].getContext('2d');
window.c.clear = window.o.clear = function() {
this.clearRect(0, 0, width(), height());
}
2014-02-01 18:18:29 +00:00
window.settings = {
stroke: true,
fill: false,
2014-02-05 13:02:07 +00:00
lineWidth : 2,
color : 'black',
2014-02-01 18:18:29 +00:00
type: 'sketch',
lineCap: 'round',
2014-02-02 20:16:28 +00:00
lineJoin: 'round',
furLength: 50,
2014-02-06 16:18:11 +00:00
connectTelorance: 40,
composite: 'source-over',
shape: 'circle',
shapeStart: {},
comShape: {},
drawingLine: [],
version: 1.2
2014-02-01 18:18:29 +00:00
};
window.points = [];
window.$c = $('canvas');
2014-02-02 20:16:28 +00:00
window.points.history = [{ data: c.createImageData($c.width(), $c.height()), points: []}];
window.points.history.last = 0;
2014-02-01 18:18:29 +00:00
sizeAndPos();
2014-02-05 13:02:07 +00:00
$('.color-picker').change(function() {
var c = $(this).find('.color').val();
var caller = $(this).parent().attr('data-caller');
settings[caller] = c;
$('#set' + caller + ' span').html(c);
if( caller == 'bg' ) {
$c.first().css('background', c);
}
2014-02-05 13:02:07 +00:00
})
$('.color').val('#000000');
if( localStorage.getItem('sawTips') != settings.version ) {
$('.tour').removeClass('hidden');
localStorage.setItem('sawTips', settings.version);
}
2014-02-05 13:02:07 +00:00
2014-02-01 18:18:29 +00:00
})