drawing app QUESTIONS! help would be amazing

Hi, I am currently working on a drawing app. However, I want to make it better then it is right now. These are the main things i have been wanting to add–a video/site links on how to do these would be super amazing!

1)undo/redo

2)fill tool

3)draw straight line!

  1. custom brushes

  2. super simple zoom with fingers no rotation needed

6)possibly take a pic with ipad then be able to draw on it.

any help or direction would be super amazing!

  1. Undo/redo
    To implement this, just keep a table of “actions” as your history, then revert to/reapply to the correct index when you toggle the undo/redo function.

Pseudocode:
[lua]
history = {}
currentHistory = 1

on draw release = [add an element to history equal to {points that were drawn on this stroke}, and increment currentHistory]

to undo = [delete the last lines, and decrement currentHistory]
to redo = [draw a line according to the points in history[currentHistory], and increment currentHistory]
[/lua]

[edit] Sorry, looks like the forum code highlighter has broken the formatting :frowning:

Don’t forget to clear the history up to your current point when you draw after undoing.

  1. I think this is quite complicated, and I can’t give you any viable code off the top of my head. My initial response (based on Corona’s inability to efficiently examine pixels) would be to keep a table of polygons based on where your lines are drawn, then fill them in with a function like horacebury’s polygon fill function.

  2. Add a drawing listener that just stores the start x/y location of the touch, then draws a line from the start to the end, instead of lines all the way along the touch.

  3. Instead of drawing a vector line (which I assume you’re doing), scale an image to the length of your line, rotate it, and position it accordingly.

  4. I’m fairly sure there’s a pinch-zoom library on the code exchange; that’s an easy way to do it.

  5. Check out the Corona sample ‘Media/PhotoPicker’. Basically, what you’ll do is import a photo, and put it in the background to draw on.

  • Caleb

  • C

  1. Undo/redo
    To implement this, just keep a table of “actions” as your history, then revert to/reapply to the correct index when you toggle the undo/redo function.

Pseudocode:
[lua]
history = {}
currentHistory = 1

on draw release = [add an element to history equal to {points that were drawn on this stroke}, and increment currentHistory]

to undo = [delete the last lines, and decrement currentHistory]
to redo = [draw a line according to the points in history[currentHistory], and increment currentHistory]
[/lua]

[edit] Sorry, looks like the forum code highlighter has broken the formatting :frowning:

Don’t forget to clear the history up to your current point when you draw after undoing.

  1. I think this is quite complicated, and I can’t give you any viable code off the top of my head. My initial response (based on Corona’s inability to efficiently examine pixels) would be to keep a table of polygons based on where your lines are drawn, then fill them in with a function like horacebury’s polygon fill function.

  2. Add a drawing listener that just stores the start x/y location of the touch, then draws a line from the start to the end, instead of lines all the way along the touch.

  3. Instead of drawing a vector line (which I assume you’re doing), scale an image to the length of your line, rotate it, and position it accordingly.

  4. I’m fairly sure there’s a pinch-zoom library on the code exchange; that’s an easy way to do it.

  5. Check out the Corona sample ‘Media/PhotoPicker’. Basically, what you’ll do is import a photo, and put it in the background to draw on.

  • Caleb

  • C