Basic pin rendering
This commit is contained in:
parent
259786ad98
commit
7427a02842
38 changed files with 510 additions and 115 deletions
src/common/canvas/helpers
14
src/common/canvas/helpers/useTransform.ts
Normal file
14
src/common/canvas/helpers/useTransform.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { Transform } from '../../math/classes/Transform'
|
||||
import { multiply } from '../../../modules/vector2/helpers/basic'
|
||||
|
||||
export const useTransform = (
|
||||
ctx: CanvasRenderingContext2D,
|
||||
{ position, rotation, scale }: Transform
|
||||
) => {
|
||||
ctx.translate(...position)
|
||||
ctx.translate(scale[0] / 2, scale[1] / 2)
|
||||
|
||||
ctx.rotate(rotation)
|
||||
|
||||
return new Transform(multiply(scale, -0.5), scale, 0)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue