-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtransforms.go
34 lines (27 loc) · 1.01 KB
/
transforms.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package giocanvas
import "gioui.org/op"
// Transformations
// Translate moves current location by (x,y) using percentage-based measures
func (c *Canvas) Translate(x, y float32) op.TransformStack {
x, y = dimen(x, y, c.Width, c.Height)
return c.AbsTranslate(x, y)
}
// Rotate around (x,y) by angle (radians) using percentage-based measures
func (c *Canvas) Rotate(x, y, angle float32) op.TransformStack {
x, y = dimen(x, y, c.Width, c.Height)
return c.AbsRotate(x, y, angle)
}
// Scale centered at (x,y) by factor using percentage-based measures
func (c *Canvas) Scale(x, y, factor float32) op.TransformStack {
x, y = dimen(x, y, c.Width, c.Height)
return c.AbsScale(x, y, factor)
}
// Shear the object centered at (x,y) using x-angle and y-angle (radians) using percentage-based measures
func (c *Canvas) Shear(x, y, ax, ay float32) op.TransformStack {
x, y = dimen(x, y, c.Width, c.Height)
return c.AbsShear(x, y, ax, ay)
}
// EndTransform ends a transformation
func EndTransform(stack op.TransformStack) {
stack.Pop()
}