Skip to content

Commit

Permalink
Add detail to README.md about how to draw a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyTim committed May 25, 2024
1 parent 30d2a73 commit e38b291
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ An easy to use, themeable component for randomising choices and prizes.
- Callbacks for events like `onSpin` and `onCurrentIndexChange`.
- Clockwise and anticlockwise spinning.

## Examples

- [Basic ESM](https://crazytim.github.io/spin-wheel/examples/esm)
- [Basic IIFE](https://crazytim.github.io/spin-wheel/examples/iife)
- [Basic Vue](https://crazytim.github.io/spin-wheel/examples/vue3/dist)
- [Spin to a specific item](https://crazytim.github.io/spin-wheel/examples/spin-to-item)
- [Multiple Wheels](https://crazytim.github.io/spin-wheel/examples/multiple)
- [Themes](https://crazytim.github.io/spin-wheel/examples/themes)
- [Developer playground (for testing and troubleshooting)](https://crazytim.github.io/spin-wheel/examples/playground)

## Installation

### ESM
Expand Down Expand Up @@ -78,15 +88,16 @@ wheel.spinToItem(winningItemIndex, duration, true, 2, 1, easing)

If precision is not important, you can use `Wheel.spin()` to immediately start spinning the wheel at a certain speed, which will be reduced over time according to `Wheel.rotationResistance`. You can also set `Wheel.isInteractive = true` to allow the user to spin the wheel themselves by dragging or flicking.

## Examples
## How to draw the pointer

- [Basic ESM](https://crazytim.github.io/spin-wheel/examples/esm)
- [Basic IIFE](https://crazytim.github.io/spin-wheel/examples/iife)
- [Basic Vue](https://crazytim.github.io/spin-wheel/examples/vue3/dist)
- [Spin to a specific item](https://crazytim.github.io/spin-wheel/examples/spin-to-item)
- [Multiple Wheels](https://crazytim.github.io/spin-wheel/examples/multiple)
- [Themes](https://crazytim.github.io/spin-wheel/examples/themes)
- [Developer playground (for testing and troubleshooting)](https://crazytim.github.io/spin-wheel/examples/playground)
The wheel doesn't have a built-in pointer, instead you set `Wheel.pointerAngle` and draw the pointer yourself. This is because there are many ways you might want the pointer to appear and behave, for example you might want to animate it.

Your options for drawing the pointer are:

- Overlay an image using `Wheel.overlayImage`
- Overlay something using the DOM

Feel free to use an image from one of the examples above.

## Configuration

Expand Down Expand Up @@ -140,7 +151,7 @@ Name | Default Value | Description
`items` | `[]` | The items to show on the wheel.
`lineColor` | `'#000'` | The [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) of the lines between the items.
`lineWidth` | `1` | The width (in pixels) of the lines between the items.
`pixelRatio` | `0` | The pixel ratio used to render the wheel.</p><p>Values above 0 will produce a sharper image at the cost of performance.</p><p>A value of `0` will cause the pixel ratio to be automatically determined using `window.devicePixelRatio`.
`pixelRatio` | `0` | The pixel ratio used to draw the wheel.</p><p>Values above 0 will produce a sharper image at the cost of performance.</p><p>A value of `0` will cause the pixel ratio to be automatically determined using `window.devicePixelRatio`.
`radius` | `0.95` | The radius of the wheel (as a percent of the container's smallest dimension).
`rotation` | `0` | The rotation (angle in degrees) of the wheel.</p><p>The first item will be drawn clockwise from this point.
`rotationResistance` | `-35` | The amount that `rotationSpeed` will be reduced by every second. Only in effect when `rotationSpeed !== 0`.</p><p>Set to `0` to spin the wheel infinitely.
Expand Down
2 changes: 1 addition & 1 deletion src/wheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ export class Wheel {
}

/**
* The pixel ratio used to render the wheel.
* The pixel ratio used to draw the wheel.
* Values above 0 will produce a sharper image at the cost of performance.
* A value of `0` will cause the pixel ratio to be automatically determined using `window.devicePixelRatio`.
*/
Expand Down

0 comments on commit e38b291

Please sign in to comment.