ScaleAbout
This commit is contained in:
parent
52d268d7a2
commit
e08199f06f
@ -101,6 +101,7 @@ SetFillRule(fillRule FillRule)
|
||||
Identity()
|
||||
Translate(x, y float64)
|
||||
Scale(x, y float64)
|
||||
ScaleAbout(sx, sy, x, y float64)
|
||||
Rotate(angle float64)
|
||||
RotateAbout(angle, x, y float64)
|
||||
Shear(x, y float64)
|
||||
|
@ -388,6 +388,10 @@ func (dc *Context) Scale(x, y float64) {
|
||||
dc.matrix = dc.matrix.Scale(x, y)
|
||||
}
|
||||
|
||||
func (dc *Context) ScaleAbout(sx, sy, x, y float64) {
|
||||
dc.matrix = dc.matrix.ScaleAbout(sx, sy, x, y)
|
||||
}
|
||||
|
||||
func (dc *Context) Rotate(angle float64) {
|
||||
dc.matrix = dc.matrix.Rotate(angle)
|
||||
}
|
||||
|
11
matrix.go
11
matrix.go
@ -30,6 +30,13 @@ func Scale(x, y float64) Matrix {
|
||||
}
|
||||
}
|
||||
|
||||
func ScaleAbout(sx, sy, x, y float64) Matrix {
|
||||
a := Translate(-x, -y)
|
||||
b := Scale(sx, sy)
|
||||
c := Translate(x, y)
|
||||
return a.Multiply(b).Multiply(c)
|
||||
}
|
||||
|
||||
func Rotate(angle float64) Matrix {
|
||||
c := math.Cos(angle)
|
||||
s := math.Sin(angle)
|
||||
@ -86,6 +93,10 @@ func (a Matrix) Scale(x, y float64) Matrix {
|
||||
return Scale(x, y).Multiply(a)
|
||||
}
|
||||
|
||||
func (a Matrix) ScaleAbout(sx, sy, x, y float64) Matrix {
|
||||
return ScaleAbout(sx, sy, x, y).Multiply(a)
|
||||
}
|
||||
|
||||
func (a Matrix) Rotate(angle float64) Matrix {
|
||||
return Rotate(angle).Multiply(a)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user