Show HN: MirrorDraw – A small project to draw on a canvas
mirrordraw.herokuapp.com
mirrordraw.herokuapp.com
This was a small project to learn to use canvas and Ruby on Rails better. It isn't an ongoing project but I would like to keep learning and get feedback on what I can improve on. Especially where I am doing something wrong in the javascript or completely against how I should be using RoR.
Source: https://github.com/Rhebel/MirrorDrawing
edit: I have a huge question for anybody who knows a solution. I don't know how to search for this properly. In the console you can adjust the line width manually; MD.PX = 20
Draw something after doing that and things are strange. I think it's because the line doesn't know which direction it should go between points so it seems to be pretty random. I had an idea that adding points would help but I don't know and I'd love to figure that out.
I tested the app with an older version of chrome (24) and it worked well. Drawing and downloading was successful, although my supposed "artistic" skills are more than a bit embarrassing. I saw no errors when opening the downloaded file in gimp. I liked how you used a transparent background in the image --this violated the principle-of-least surprise due to the white background of the website, but at least for me it was a pleasant surprise.
Lastly, two possible suggested improvements, well three actually. (1) Allow background color to be set on resulting image (i.e. no surprises). (2) Enable sharing the image as a link of some sort, or via social media, or something like that. (3) Auto-detect viewport size and size the new image/canvas accordingly.
What I would do to handle this is when you are drawing fat lines, draw a 20px diameter filled circle at the beginning point, then the line to the ending point, then a 20px diameter circle at the end point. This will give you strokes with rounded ends. Another possible improvement along this lines is that you could paint a circle when someone first clicks on the canvas rather than only when they move the mouse.
The way this works is that I add points to an array while dragging. There is a loop that adds a point and draws a line to the last point. I think that interval of drawing is what slows it down but that is just what I felt like it had to be.
One thing I would improve: When drawing on the left half and moving to the right half without releasing the mouse, the drawing stops. I would expect the drawing to continue on the right canvas, while mirroring back to the left canvas, and vice-versa.
Maybe it's a browser specific, I'm on Chrome 38.0.2125.122, OSX 10.10.
This and the kaleidoscope are two things that could keep me busy.
I could make it so that when drawing it reverses from the middle so that it was just one canvas. Well, I could try.
It only works with touch events, not mouse, so mouse support would make a nice next step.