Is there a way to make a line correct to straight when the user holds down at the end of the drawn line for a few seconds? Like how in GoodNotes, if you hold the pen down at the end of the line, it corrects it to perfectly straight.
You could try making a Sprite with the picture of a thin long line, and rotate and expand the sprite as you draw the line, pinning one corner of the Sprite against the starting point.
As you drag across the Canvas, rotate and expand the Sprite to keep the drawing point as the opposite corner of the sprite to the origin.
At end of draw, do the actual line draw.
(I have not tried this.)
Simplest, touch up event after drawing line, having captured the first and last coordinates?
Can you expand upon how to do this?
Some example blocks
The downside of this simple example is if you then draw another line across a line already drawn, it will "blank" where the line intersects, if it was not very straight.
To over come this, either save each drawn straight line coordinates, use clear.canvas, then draw all the saved lines,
or
take an image of the canvas after drawing a line, then clear.canvas and replace the canvas background with that image.
There are probably other / better ways...
Reverse the block order in Button3, lest you wipe the newly drawn line.
Maybe better, requires a button to set whether straight lines should be drawn. User can hold position on canvas to draw shape with straight lines. User can stay on or lift off the canvas after drawing.
Drawing quickly with straight lines off may draw some straight lines ? So draw slowly...
correctDrawLine2.aia (5.1 KB)
Here is a version of the example I posted earlier that does exactly (?) that.
Start scribbling your drawn line; when you finish drawing, keep your finger holding the finger (pen?) down when you are at the end of the line; after a few seconds, release your finger. When released, the line corrects to a straight line without having to use a button to straighten the line. It uses the TouchUp block event handler to straighten the line you just drew instead of a Button event handler.
DrawLineandstraighten3a.aia (2.8 KB)



