Name Picker Wheel
Technical Concepts
Arc Calculations: The wheel is divided into segments using the formula:
$$\text{Arc Size} = \frac{2\pi}{\text{Number of Names}}$$Each segment is then filled with a unique color based on the
HSLcolor space to ensure variety regardless of how many names are added.The Physics of Spinning: We don't just stop the wheel abruptly. The
easeOutfunction simulates friction. It starts fast and slows down progressively, making the outcome feel suspenseful and fair.Determining the Winner: Since the pointer is at the top ($-90^\circ$ or $270^\circ$ in canvas space), the code calculates the final
startAngle, normalizes it to $360^\circ$, and maps that back to the array index of names.Responsiveness: The UI uses a flexible
flex-directionthat shifts from a side-by-side view (Desktop) to a stacked view (Mobile). The Canvas is set tomax-width: 100%to ensure it doesn't overflow smaller screens.