Created
July 5, 2011 19:06
-
-
Save austinbv/1065598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize = -> | |
canvas = $('#drawn').get 0 | |
window.c = canvas.getContext '2d' | |
$('#drawn').parent().append($('<canvas id="temp" height="'+canvas.height+'" width="'+canvas.width+'"></canvas>')) | |
window.d = $('#temp').get(0).getContext '2d' | |
window.c.lineJoin = d.lineJoin = "round" | |
window.c.lineCap = d.lineJoin = "round" | |
window.c.strokeStyle = d.strokeStyle = "#"+ghex | |
window.c.lineWidth = d.lineWidth = 1 | |
@tool = new tools.pencil | |
$('#container canvas').bind 'mousedown mousemove mouseup', mouse_draw | |
mouse_draw = (e) -> | |
current_position = find_position(this) | |
e._x = e.clientX - current_position.x | |
e._y = e.clientY - current_position.y | |
e._x = e._x*css_offset.x | |
e._y = e._y*css_offset.y | |
func = tool[event_map[e.type]] | |
func(e) if func? | |
down = true if event_map[e.type] == "down" | |
if event_map[e.type] == "up" | |
down = false | |
$(window).ready -> | |
initialize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment