Begin to work on matrix transformation (does not yet really work)
This commit is contained in:
parent
2d02464b73
commit
ae9b990671
1 changed files with 5 additions and 7 deletions
|
@ -91,18 +91,15 @@ func (gc *GraphicContext) Rotate(angle float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gc *GraphicContext) Translate(tx, ty float) {
|
func (gc *GraphicContext) Translate(tx, ty float) {
|
||||||
ox, oy := gc.current.path.LastPoint()
|
tr := NewTranslationMatrix(tx, ty)
|
||||||
tr := NewTranslationMatrix(ox, oy)
|
gc.current.tr.Compose(tr)
|
||||||
tr2 := NewTranslationMatrix(tx, ty)
|
|
||||||
tr1 := tr.GetInverseTransformation()
|
|
||||||
gc.current.tr.Compose(tr).Compose(tr2).Compose(tr1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gc *GraphicContext) Scale(sx, sy float) {
|
func (gc *GraphicContext) Scale(sx, sy float) {
|
||||||
ox, oy := gc.current.path.LastPoint()
|
ox, oy := gc.current.path.LastPoint()
|
||||||
tr := NewTranslationMatrix(ox, oy)
|
tr := NewTranslationMatrix(ox, oy)
|
||||||
tr2 := NewScaleMatrix(sx, sy)
|
tr2 := NewScaleMatrix(sx, sy)
|
||||||
tr1 := tr.GetInverseTransformation()
|
tr1 := tr.GetInverseTransformation()
|
||||||
gc.current.tr.Compose(tr).Compose(tr2).Compose(tr1)
|
gc.current.tr.Compose(tr).Compose(tr2).Compose(tr1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +153,7 @@ func (gc *GraphicContext) Save() {
|
||||||
context.cap = gc.current.cap
|
context.cap = gc.current.cap
|
||||||
context.join = gc.current.join
|
context.join = gc.current.join
|
||||||
context.path = gc.current.path.Copy()
|
context.path = gc.current.path.Copy()
|
||||||
|
copy(context.tr[:], gc.current.tr[:])
|
||||||
context.previous = gc.current
|
context.previous = gc.current
|
||||||
gc.current = context
|
gc.current = context
|
||||||
}
|
}
|
||||||
|
@ -234,7 +232,7 @@ func (gc *GraphicContext) RArcTo(dcx, dcy, rx, ry, startAngle, angle float) {
|
||||||
gc.current.path.RArcTo(dcx, dcy, rx, ry, startAngle, angle)
|
gc.current.path.RArcTo(dcx, dcy, rx, ry, startAngle, angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gc *GraphicContext) Close() {
|
func (gc *GraphicContext) ClosePath() {
|
||||||
gc.current.path.Close()
|
gc.current.path.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue