How “Draw a Perfect Star” actually calculates accuracy
The goal of this system is not to “recognise” a star visually. It turns both your drawing and a perfect star into comparable point data, then measures how far apart they are.
This makes scoring fast, deterministic, and surprisingly stable.
Input capture
While you draw, the app records raw mouse positions:
path = [(x1, y1), (x2, y2), etc etc]
This data is noisy and depends heavily on speed and polling/sampling rate.
Resampling
The stroke is converted into a fixed number of evenly spaced points (120).
This removes:
-
drawing speed differences
-
uneven mouse sampling
Now every drawing has a consistent structure.
Normalisation
The shape is transformed so comparison is fair:
-
centred around (0, 0)
-
scaled so max radius = 1
This removes position/size- only shape remains.
Reference star
A perfect 5-pointed star is generated mathematically using polar coordinates and sine-based radius switching.
It is also sampled into 120 points so it matches the user format.
Comparison
Each user point is compared directly to the corresponding star point-
error += distance(user[i], star[i])
This produces an average geometric deviation across the full shape.
Scoring
Final score is computed as:
score = 100 - error * 120
Then clamped between 0 and 100.
Summary
The system works by converting both shapes into normalized point sequences and measuring their geometric distance.
Comments 4
Great project, and the math seems promising. May i ask, can you ship a project only 1 time or after youve shipped “draw a perfect star” are you allowed to ship a newer version?
this is SO COOL oh my godh
the resampling to 120 fixed points is actually smart - removes all the speed bias. curious what happens when someone draws really slowly vs really fast now that it’s normalized
This is so awesome! I tried your project and found it fun!
Sign in to join the conversation.