if start_point.distance_to( touch_point ) > 50: # min distance
if start_point.angle_to( touch_point ) > rad2deg( 30 ) and < rad2deg( 90 ):
# this is example how detect line with angle i.e. triangle
if you need fixed shapes (triangle):
triangle = 0
if start_point.distance_to( touch_point ) > 100 and < 200:
var angle = start_point.angle_to( touch_point )
if triangle == 0: # stage of triangle
if angle > rad2deg( 30 ) and angle < rad2deg( 70 ):
triangle = 1
start_point = touch_point # this is basic mechanics
elif triangle == 1:
# next angle
hard to explain all variants, but, you need aprox this code.
and upgrade: start_point = touch_point ---- in best case need: touch_points = [] and touch_points.append(touch_point)
if touch_points.back().distance_to( touch_point ) > 100:
then you need line between last 2 poins (create vector) and if angle between this vector and current touch point > 30deg. (determination error), then touch_points.append(touch_point)
Finale, when user unpress touch, need just …
if touch_points.size() == 3: # triangle
for i in touch_points:
#check angles
Thank you so much for answering.
I will give this a try when I get home!
pelvichan | 2019-12-21 14:24
Or another variant:
Collect all points if if touch_points.back().distanceto( touch_point ) > 50 (precision), and add to array.
then analize array points if points[“angle”].max < ~30 (max angle bitween each) - it seems to be circle…
if have 3 angles = ~60 - triangle
if 4 angles > 80 and < 100 - square
or if you need pentagram… you need have 5 angles ~36 deg each.
P.S. and check angle direction… if you have 2 angles clockwise and 2 conter and start and end point in some place - this is not square… )
and remember - check distance bitween start and and point (in some case not i.e. line or “Z”))
SuperDIMMaX | 2019-12-21 15:24
small addon: you can make check lotal length of vectors for come reason…
if shape need some size, or use for more powerfull magick cast - small triangle - typical fireball - big - more powerfull…
SuperDIMMaX | 2019-12-21 15:50
variant for curves (circle):
find in array min/max x and y point - you get square - find center, check distance bitween each point and center if min and max distance ~ equal - this is circle…
in “infinity” - need intersection in center…