Page 1 of 1

Drawing question

PostPosted: Fri May 24, 2013 3:33 pm
by sonne1711
Hi!

I have a questions regards drawing. I hope someone can help me on this.

What I want to create is that if I press a mousebutton the drawing starts.
Then it draw a line from the starting point at which I pressed the mouse to the mouse position.
At somepoint at the screen the starting point changed. Then after this the line has to be draw from this new starting point to the mouse.
And if I release the mouse button its finished.

My code for drawing is:

if (draw == 1) {
if (startdraw == 1) { // check if started the drawing
setpen(10, 10, 10, 0.0, 3);
erase(10,10,10,1);
moveto (mstartx,mstarty);
screen_to_actor(&xmouse, &ymouse);
lineto (xmouse,ymouse);
} else {
startdraw = 1;
screen_to_actor(&xmouse, &ymouse);
moveto (xmouse,ymouse);
mstartx = xmouse;
mstarty = ymouse;
}
}

So it means that I clear the last lines and draw a new line from starting point to the mouse position.
But at some checkpoints I want not to remove the line.
It means I want a line from point 1 to point 2 and then to point 3 and to point 4 ...
Any idea how to solve it?

Thx,

Re: Drawing question

PostPosted: Sun May 26, 2013 12:25 am
by skydereign
Not really sure what you want.
sonne1711 wrote:What I want to create is that if I press a mousebutton the drawing starts.
Then it draw a line from the starting point at which I pressed the mouse to the mouse position.

I understand this, but I'm not sure what you mean by the following.
sonne1711 wrote:At somepoint at the screen the starting point changed. Then after this the line has to be draw from this new starting point to the mouse.

Do you mean after it has moved a certain distance from the starting point, it keeps the line, and creates a new line by putting the starting point at the last end point? Essentially making it so you now have two lines connected? Or is this off entirely?

Re: Drawing question

PostPosted: Mon May 27, 2013 12:29 pm
by sonne1711
I try to explain better.

My starting screen looks like this:
sample0.gif
sample0.gif (945 Bytes) Viewed 1717 times


Then I press a mousebutton and hold it. Starting from point 1. Then I move the mouse cursor trough the screen. All the time I see a line from point 1 to the mouse cursor position. Then if I move cursor over the point 2 the starting point of the line starts at point 2. And I continue to move the mouse I see now something like you can see at this image:

sample1.gif


Then I continue the mouse to point 3 and then to point 4 and then I release the mouse button. and then I want a screen like this one:

sample2.gif


I hope you can understand it better and give me a solution how to do something like this.

Thx

Re: Drawing question

PostPosted: Mon May 27, 2013 7:44 pm
by skydereign
So essentially it is just connect the dots? I'm currently a bit busy, but I can post a small demo of this tomorrow. Do you have any experience with variables?

Re: Drawing question

PostPosted: Tue May 28, 2013 7:13 am
by sonne1711
Thank you but now I got the solution. The trick for me was to use more then one canvas.
I was not sure that the erase on one canvas has nothing to do with the second canvas.

thx