2017년 4월 16일 일요일

Canvas, drawing continued line


I'm working on an app that solves a series of calculations based on a drawn curve.
I've tried using 'canvas dragged' and 'canvas touched up'. 
So 'canvas dragged' sets the variables for the calculations. 'Canvas touched up' starts the calculations and displays the results.
It all works fine, I can draw several curves and the results are shown.

But now I would like the second curve to continue where the first curve ended (when the canvas is touched for the second time).
I guess this must be possible but I can not get it to work. Does anyone have a simple way to do this?

These are the blocks I've tried to use:


--
I think you should draw the line in the Canvas.TouchUp event, not in the Dragging event. Right?

-- 
Not sure if I understand this.... 
The user should draw the curve on the canvas. The calculations are based on the drawn curve.
If I use touch up event to draw the curve nothing will happen until I lift my finger of the canvas, right?

-- 
Well, If I can't see how the app works, I'm just guessing here.
I'm going to give you a generic answer to your question: If you need to continue a line from the previous point, don't use prevX and prevY as the initial points. Use the globals you updated in the Canvas.TouchUp event.
Does that makes sense? If not, please provide the aia to test it.

-- 
Aah. Makes sense now. 
It doesn't draw a fluent curve but a series of straight lines.Actually better for my purpose.
Thanks for your help Italo.

Now if I could make a "rubber band" preview of the line when dragging over the canvas it would be perfect. Still fiddling with that.... ;-)
-- 

댓글 없음:

댓글 쓰기