Reference · Cube engine and views
dragAnglefunction
The angle, in degrees, a picked layer has been dragged to: forwards is positive, and it stops at a half turn either way. quarterPx is the pixels that make a quarter turn.
Import it
import { dragAngle } from "@johnmorrisdotca/kyuubu";
Definition
function dragAngle(pick: DragPick, dx: number, dy: number, quarterPx: number): number
Parameters
| Name | Type | Description |
|---|---|---|
pick | DragPick | The layer and screen direction selected by a drag. |
dx | number | The horizontal pointer displacement in pixels. |
dy | number | The vertical pointer displacement in pixels. |
quarterPx | number | The pointer distance in pixels that makes a quarter turn. |
Returns
number
The angle, in degrees, a picked layer has been dragged to: forwards is positive, and it stops at a half turn either way. quarterPx is the pixels that make a quarter turn.
Examples
import { dragAngle } from "@johnmorrisdotca/kyuubu";
const pick = { axis: 0 as const, layer: 2, along: [1, 0] as [number, number] };
console.log(dragAngle(pick, 40, 0, 100));36What it prints (run when this page was built)