resolve bug on matrix transformation

This commit is contained in:
legoff.laurent 2010-11-26 15:08:17 +00:00
parent 5e6aa57cf2
commit 2ba52ad508
2 changed files with 8 additions and 7 deletions

View file

@ -13,8 +13,8 @@ import (
"math"
"image"
"image/png"
//"draw2d"
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
"draw2d"
//"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
)
const (
@ -421,9 +421,10 @@ func TestStar() {
for i := 0.0 ; i < 360; i = i + 10 {// Go from 0 to 360 degrees in 10 degree steps
gc.BeginPath() // Start a new path
gc.Save() // Keep rotations temporary
gc.MoveTo(144, 144)
gc.Translate(144, 144)
gc.Rotate(i * (math.Pi / 180.0)) // Rotate by degrees on stack from 'for'
gc.RLineTo(72, 0)
gc.MoveTo(0, 0)
gc.LineTo(72, 0)
gc.Stroke()
gc.Restore() // Get back the unrotated state
}

View file

@ -84,15 +84,15 @@ func (gc *GraphicContext) ComposeMatrixTransform(tr MatrixTransform) {
}
func (gc *GraphicContext) Rotate(angle float) {
gc.current.tr.Rotate(angle)
gc.current.tr = NewRotationMatrix(angle).Multiply(gc.current.tr)
}
func (gc *GraphicContext) Translate(tx, ty float) {
gc.current.tr.Translate(tx, ty)
gc.current.tr = NewTranslationMatrix(tx, ty).Multiply(gc.current.tr)
}
func (gc *GraphicContext) Scale(sx, sy float) {
gc.current.tr.Scale(sx, sy)
gc.current.tr = NewScaleMatrix(sx, sy).Multiply(gc.current.tr)
}
func (gc *GraphicContext) Clear() {