*About functions in Context only

This commit is contained in:
Michael Fogleman 2016-02-21 15:54:54 -05:00
parent add21769e5
commit 104a343597
2 changed files with 9 additions and 36 deletions

View File

@ -426,7 +426,9 @@ func (dc *Context) Scale(x, y float64) {
}
func (dc *Context) ScaleAbout(sx, sy, x, y float64) {
dc.matrix = dc.matrix.ScaleAbout(sx, sy, x, y)
dc.Translate(x, y)
dc.Scale(sx, sy)
dc.Translate(-x, -y)
}
func (dc *Context) Rotate(angle float64) {
@ -434,7 +436,9 @@ func (dc *Context) Rotate(angle float64) {
}
func (dc *Context) RotateAbout(angle, x, y float64) {
dc.matrix = dc.matrix.RotateAbout(angle, x, y)
dc.Translate(x, y)
dc.Rotate(angle)
dc.Translate(-x, -y)
}
func (dc *Context) Shear(x, y float64) {
@ -442,7 +446,9 @@ func (dc *Context) Shear(x, y float64) {
}
func (dc *Context) ShearAbout(sx, sy, x, y float64) {
dc.matrix = dc.matrix.ShearAbout(sx, sy, x, y)
dc.Translate(x, y)
dc.Shear(sx, sy)
dc.Translate(-x, -y)
}
func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {

View File

@ -30,13 +30,6 @@ 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)
@ -47,13 +40,6 @@ func Rotate(angle float64) Matrix {
}
}
func RotateAbout(angle, x, y float64) Matrix {
a := Translate(-x, -y)
b := Rotate(angle)
c := Translate(x, y)
return a.Multiply(b).Multiply(c)
}
func Shear(x, y float64) Matrix {
return Matrix{
1, y,
@ -62,13 +48,6 @@ func Shear(x, y float64) Matrix {
}
}
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 {
return Matrix{
a.XX*b.XX + a.YX*b.XY,
@ -100,22 +79,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)
}
func (a Matrix) RotateAbout(angle, x, y float64) Matrix {
return RotateAbout(angle, x, y).Multiply(a)
}
func (a Matrix) Shear(x, y float64) Matrix {
return Shear(x, y).Multiply(a)
}
func (a Matrix) ShearAbout(sx, sy, x, y float64) Matrix {
return ShearAbout(sx, sy, x, y).Multiply(a)
}