We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › another drawing program...
Page Index Toggle Pages: 1
another drawing program... (Read 2046 times)
another drawing program...
Jan 21st, 2008, 7:42am
 

Hi all,
i'm learning Processing and this is my first work: bru55h.

http://rapidshare.com/files/85347922/bru55h.zip.html

A(nother) simple drawing program with:
1) palette (color and grayscale)
2) stroke and fill
3) zoom window
4) erase mode
5) mirror mode
6) pencil, ellipse, rectangle, spray, cross and image brush
You can load, save and start new drawing.
You can change brush parameters (color, transparence, fill, stroke, size).

To see Help press 'H'.

I'm working to add some GUI and... remove bugs.

A question:
Have you an hint to implement real 'undo' capabilities?

Thanks for viewing

cameyo

p.s. Sorry for poor english, i'm italian.
Re: another drawing program...
Reply #1 - Jan 22nd, 2008, 7:45am
 
can someone help me about Undo ?

thanks

cameyo
Re: another drawing program...
Reply #2 - Jan 22nd, 2008, 11:16am
 
the sketch is great!

I came up with this idea for your Undo method. I'm not sure it's the best, but you can give it a try :

- declare a PImage e.g. undoBuffer and a boolean variable e.g. isDrawing
- when the user starts drawing things, copy the content of the drawing window into undoBuffer (just before he starts drawing)
- let the user have fun with the pencils or whatever until he releases the mouse button...
- to undo, just copy the content of undoBuffer to the screen!

Code:
void mouseReleased() {
isDrawing = false;
}

void mousePressed() {
if (isDrawing) {
// <- draw things here
} else {
// <- copy screen to buffer here
isDrawing = true;
// <- draw things here
}
}


what do you think?

sorry for my poor english, i'm french Wink
Re: another drawing program...
Reply #3 - Jan 23rd, 2008, 7:40am
 
Thanks antiplastik!!!
I'm work to integrate your idea.

Have a nice day.

cameyo
Re: another drawing program...
Reply #4 - Jun 16th, 2009, 7:37am
 
Hello Cameyo Wink
Finally I go there  Smiley
After seen this crazzy guy Jared Tarbell  Cool
See you soon Wink
Pilou
Re: another drawing program...
Reply #5 - Jun 21st, 2009, 12:02am
 
Another method for making an Undo capability would be the Command Pattern...

Basically, every time you do something you store a new instance of a class (which just holds data about what you did) into an ArrayList or array (if you want to have a set number of undo's an array would work better).  Then, when the user wants to Undo something, you simply use the pop() method and remove whatever it was from the screen.

It's almost exactly the same as the previous example mentioned except there is very little overhead.
Page Index Toggle Pages: 1