Lol! I think I saw somebody write that once, CodPen; they just forgot the e, obviously. But upon reading it I had the funny idea of a cod being used as a pen. So... today I implemented it!
I'm gonna build it up as a drawing application. I'll add in the ability to change pen size and color and some other goodies!
But... I don't think it's working for me... The code makes sense and on a quick scan I can see what it's supposed to be doing, but I'm just getting a black canvas/screen. It's never drawing a blue line for me... I'll take an in depth look later on to see if I can get it working!
Not at all sure what was wrong the first time I was playing with it, but I threw in a few alerts to make sure all the handler functions were working and now the drawing is working! I have no way to explain that...
I like the outsideCanvas thing. That's a great idea!
Using Chrome, btw.
*and lol, you didn't steal mousemove from me. It's like saying you stole var from me! :)
Now has (very) rudimentary fill function. Was able to make this - Pic
Ctrl-click to fill colour. It will cause a stack overflow and fail disastrously on any regions bigger than about 10% of canvas :) Need to come up with a less recursive flat function I think. Make it work first... time for optimization.
I am having trouble getting the fill to work though... If I understand correctly, I'm supposed to hold ctrl and click the left mouse button within a closed off shape? I got it to work once, but I can't seem to get it to work again...
If you have a moment, would you mind explaining at a high level... like even higher than pseudo code; just kind of layman's terms... how the fill function works? I see the whole getImageData deal going on but I'm not too familiar with it. And I see the coordinates deal in there, but I'm having trouble putting it all together conceptually...
Irrespective of my lack of understanding, nice work!! :)
1
u/ForScale May 15 '16
Just a fun idea to start playing around with!
Definitely needs some work on the ux side of things...