Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method for rotation around the center #65 #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ is used to specify inputs and results for filter effects
rotates the coordinate system by r degrees, end with Gend().
<http://www.w3.org/TR/SVG11/coords.html#TransformAttribute>

RotateCenter(r float64, x, y int)
rotates arount the center coordinate system by r degrees, end with Gend()

TranslateRotate(x, y int, r float64)
translates the coordinate system to (x,y), then rotates to r degrees, end with Gend().

Expand Down
6 changes: 6 additions & 0 deletions svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ func (svg *SVG) SkewXY(ax, ay float64) { svg.Gtransform(skewX(ax) + " " + skewY(
// Standard Reference: http://www.w3.org/TR/SVG11/coords.html#TransformAttribute
func (svg *SVG) Rotate(r float64) { svg.Gtransform(rotate(r)) }

// RotateCenter rotates arount the center coordinate system by r degrees, end with Gend()
func (svg *SVG) RotateCenter(r float64, x, y int) { svg.Gtransform(rotateCenter(r, x, y)) }

// TranslateRotate translates the coordinate system to (x,y), then rotates to r degrees, end with Gend()
func (svg *SVG) TranslateRotate(x, y int, r float64) {
svg.Gtransform(translate(x, y) + " " + rotate(r))
Expand Down Expand Up @@ -1020,6 +1023,9 @@ func skewY(angle float64) string { return fmt.Sprintf(`skewY(%g)`, angle) }
// rotate returns the rotate string for the transform
func rotate(r float64) string { return fmt.Sprintf(`rotate(%g)`, r) }

// rotateCenter returns the rotate string for the transform
func rotateCenter(r float64, x, y int) string { return fmt.Sprintf(rotate(%g %d %d), r, x, y) }

// translate returns the translate string for the transform
func translate(x, y int) string { return fmt.Sprintf(`translate(%d,%d)`, x, y) }

Expand Down