The Roulette Wheel is an interactive web application that allows users to create a customizable wheel with different items, spin it randomly, and get a result. It's a versatile tool that can be used for decision making, games, or random selection processes. I got the idea for ths app when me and group of my friends weren able to decide for witch restaurant to visit. When I started to make this my idea was to make it as universal as possible. App is hosted at spin.dudo.fi
- Add Items: Enter one or multiple items separated by commas or semicolons
- Clear Items: Remove all items from the wheel
- Dice Mode: Quickly transform the wheel into a 6-sided die
- Spin Wheel: Randomly spin the wheel to select an item
- Visual Feedback: Color-coded wheel sections with item labels
- A heading and description
- Input field for adding items
- Buttons for core functions (Add, Clear, Dice, Spin)
- A list display showing current items
- Canvas element for rendering the wheel
- Pointer element indicating the selected item
- Centered layout with Arial font
- Wheel rendered as a circle with a black border
- Red pointer to indicate the selected section
- Smooth transition animation for spinning
items: Array storing all items added to the wheelwheel: Reference to the canvas elementctx: 2D drawing context for the canvasangle: Tracks the current rotation angle
-
addItem()- Captures text from the input field
- Splits input by commas or semicolons
- Adds each item to the items array
- Updates the visual list and wheel display
- Clears the input field
-
updateItemList()- Clears the existing list display
- Creates list elements for each item
- Appends items to the display list
-
clearItems()- Resets the items array to empty
- Updates the visual list and wheel display
-
makeDice()- Sets the items array to numbers 1-6
- Updates the visual list and wheel display
-
drawWheel()- Clears the canvas
- Calculates slice angle based on number of items
- Uses 5 distinct colors (yellow, orange, pink, blue, green)
- Ensures adjacent slices have different colors
- Draws each slice with its label centered
-
spinWheel()- Validates that items exist
- Calculates a random number of rotations (5-14 full spins)
- Randomly selects a section to land on
- Applies CSS transform to animate the rotation
-
Adding Items:
- Type a single item and click "Add", or
- Enter multiple items separated by commas (e.g., "Red, Blue, Green") and click "Add"
-
Creating a Dice:
- Click the "Dice" button to automatically create a 6-sided die
-
Clearing the Wheel:
- Click "Clear" to remove all items
-
Spinning the Wheel:
- Click "Spin" to randomly rotate the wheel
- The wheel will stop with the pointer indicating the selected item
- The application uses HTML5 Canvas for rendering the wheel
- CSS transitions provide smooth animation
- Color selection algorithm ensures visual distinction between adjacent sections
- The wheel will not spin if no items have been added
- Sound effects for spinning and selection
- Option to save and load different wheel configurations
- Adjustable spin time and animation effects
- Mobile-friendly touch controls
- Ability to remove individual items
- Custom color selection for wheel sections