Skip to content

Instantly share code, notes, and snippets.

@NHQ
Last active August 29, 2015 13:56
Show Gist options
  • Save NHQ/9041612 to your computer and use it in GitHub Desktop.
Save NHQ/9041612 to your computer and use it in GitHub Desktop.
// the base module
module.exports = function(canvas){
if('string' == typeof canvas) canvas = dcoument.getElementById(canvas)
touchdown.start(canvas)
var ctx = window.ctx = canvas.getContext('2d')
var pen = basic(ctx)
ctx.translate(0.5, 0.5)
ctx.lineWidth = 10
ctx.globalCompositeOperation = 'destination-over';
ctx.strokeStyle = 'rgba(50, 205, 33, .31)'
canvas.addEventListener('touchdown', function(e){pen.down(e.detail)})
canvas.addEventListener('deltavector', function(e){pen.move(e.detail)})
canvas.addEventListener('liftoff', function(e){pen.up(e.detail)})
}
// the pen module
var trig = require('../trig')
module.exports = function(ctx, denit){
var lasti, d = 0;
return {
down: touchdown,
move: deltavector,
up: liftoff
}
function touchdown(evt){
ctx.beginPath()
ctx.moveTo(evt.x, evt.y)
last = [evt.x, evt.y]
}
function deltavector(evt){
ctx.lineTo(evt.x, evt.y)
ctx.stroke()
}
function liftoff(evt){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment