ShearAbout
This commit is contained in:
parent
1d5fd3d775
commit
b77c5f2881
@ -101,10 +101,11 @@ SetFillRule(fillRule FillRule)
|
|||||||
Identity()
|
Identity()
|
||||||
Translate(x, y float64)
|
Translate(x, y float64)
|
||||||
Scale(x, y float64)
|
Scale(x, y float64)
|
||||||
ScaleAbout(sx, sy, x, y float64)
|
|
||||||
Rotate(angle float64)
|
Rotate(angle float64)
|
||||||
RotateAbout(angle, x, y float64)
|
|
||||||
Shear(x, y float64)
|
Shear(x, y float64)
|
||||||
|
ScaleAbout(sx, sy, x, y float64)
|
||||||
|
RotateAbout(angle, x, y float64)
|
||||||
|
ShearAbout(sx, sy, x, y float64)
|
||||||
TransformPoint(x, y float64) (tx, ty float64)
|
TransformPoint(x, y float64) (tx, ty float64)
|
||||||
InvertY()
|
InvertY()
|
||||||
Push()
|
Push()
|
||||||
|
@ -404,6 +404,10 @@ func (dc *Context) Shear(x, y float64) {
|
|||||||
dc.matrix = dc.matrix.Shear(x, y)
|
dc.matrix = dc.matrix.Shear(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dc *Context) ShearAbout(sx, sy, x, y float64) {
|
||||||
|
dc.matrix = dc.matrix.ShearAbout(sx, sy, x, y)
|
||||||
|
}
|
||||||
|
|
||||||
func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {
|
func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {
|
||||||
return dc.matrix.TransformPoint(x, y)
|
return dc.matrix.TransformPoint(x, y)
|
||||||
}
|
}
|
||||||
|
15
matrix.go
15
matrix.go
@ -56,12 +56,19 @@ func RotateAbout(angle, x, y float64) Matrix {
|
|||||||
|
|
||||||
func Shear(x, y float64) Matrix {
|
func Shear(x, y float64) Matrix {
|
||||||
return Matrix{
|
return Matrix{
|
||||||
1, x,
|
1, y,
|
||||||
y, 1,
|
x, 1,
|
||||||
0, 0,
|
0, 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ShearAbout(sx, sy, x, y float64) Matrix {
|
||||||
|
a := Translate(-x, -y)
|
||||||
|
b := Shear(sx, sy)
|
||||||
|
c := Translate(x, y)
|
||||||
|
return a.Multiply(b).Multiply(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (a Matrix) Multiply(b Matrix) Matrix {
|
func (a Matrix) Multiply(b Matrix) Matrix {
|
||||||
return Matrix{
|
return Matrix{
|
||||||
a.XX*b.XX + a.YX*b.XY,
|
a.XX*b.XX + a.YX*b.XY,
|
||||||
@ -108,3 +115,7 @@ func (a Matrix) RotateAbout(angle, x, y float64) Matrix {
|
|||||||
func (a Matrix) Shear(x, y float64) Matrix {
|
func (a Matrix) Shear(x, y float64) Matrix {
|
||||||
return Shear(x, y).Multiply(a)
|
return Shear(x, y).Multiply(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a Matrix) ShearAbout(sx, sy, x, y float64) Matrix {
|
||||||
|
return ShearAbout(sx, sy, x, y).Multiply(a)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user