Hi friends!
I am trying to make a quick, simple drawing tool for user input for my app but not sure I'm going about it the right way.
What I've tried so far: (1) placing a sprite at every point hit while the user was moving their finger around - when I moved my finger too fast the points became very spread out so this didn't work and (2) the same method as earlier but modifying the previous sprite to bridge the gap - it looks mostly fine now but when I draw a sharp corner the line sticks out sharply.
Here is my current function but again, I'm probably trying to do this the hard way & would appreciate any help! Don't need any edit / undo/ etc capabilities, just need to let the user draw briefly!
function Drawing()
draw_width as integer = 3
current_sprite = 99
// wait until user presses the screen
repeat
Sync()
until GetPointerPressed() <> 0 and GetPointerX() > window_left and GetPointerX() < window_right and GetPointerY() > window_top and GetPointerY() < window_bottom
// draw sprites at points hit
repeat
// draw sprites at points
CreateSprite(current_sprite, 4)
SetSpriteSize(current_sprite, draw_width - 1, -1)
SetSpriteOffset(current_sprite, GetSpriteWidth(current_sprite) / 2, GetSpriteHeight(current_sprite) / 2)
SetSpritePositionByOffset(current_sprite, GetPointerX(), GetPointerY())
SetSpriteDepth(current_sprite, 7)
SetSpriteColorAlpha(current_sprite, 255)
// if the sprite is not the first
if current_sprite <> 62
// adjust the last sprite to meet the current one
// calculate angle of rotation
x_difference as float
x_difference = ( - GetSpriteXByOffset(current_sprite) + GetSpriteXByOffset(current_sprite - 1) )
y_difference as float
y_difference = ( - GetSpriteYByOffset(current_sprite) + GetSpriteYByOffset(current_sprite - 1) ) * xy_scaler
angle as float
angle = ATan(y_difference / x_difference)
// rotate the line
SetSpriteAngle(current_sprite - 1, angle)
// calculate and set line length
length as float
length = Sqrt(x_difference ^ 2 + y_difference ^ 2)
SetSpriteSize(current_sprite - 1, 4 * length, draw_width)
SetSpriteOffset(current_sprite - 1, GetSpriteWidth(current_sprite - 1) / 2, GetSpriteHeight(current_sprite - 1) / 2)
SetSpritePositionByOffset(current_sprite, GetPointerX(), GetPointerY())
endif
inc current_sprite
Sync()
until GetPointerReleased() <> 0 or current_sprite = 1098 or GetPointerX() < window_left or GetPointerX() > window_right or GetPointerY() < window_top or GetPointerY() > window_bottom
endfunction