summaryrefslogtreecommitdiff
path: root/fpdftrans.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@gmail.com>2015-07-07 11:10:07 -0400
committerKurt Jung <kurt.w.jung@gmail.com>2015-07-07 11:10:07 -0400
commitb09a1c5eef4ec4c053c0ec22da4e9f147aae73e4 (patch)
tree182a04fddfa52da1ad5c5c82d8a9338744992ed0 /fpdftrans.go
parent8e1fd6fdd35517c1035ff353ca3cdc1e88bb82f9 (diff)
Convert sequential examples to ones that are bound to gofpdf methods.
Diffstat (limited to 'fpdftrans.go')
-rw-r--r--fpdftrans.go34
1 files changed, 32 insertions, 2 deletions
diff --git a/fpdftrans.go b/fpdftrans.go
index b87d9b9..9cda397 100644
--- a/fpdftrans.go
+++ b/fpdftrans.go
@@ -20,8 +20,6 @@ type TransformMatrix struct {
// TransformScale(), TransformSkew(), etc. This is followed by text, drawing or
// image output and finally a call to TransformEnd(). All transformation
// contexts must be properly ended prior to outputting the document.
-//
-// See tutorial 17 for transformation examples.
func (f *Fpdf) TransformBegin() {
f.transformNest++
f.out("q")
@@ -29,6 +27,8 @@ func (f *Fpdf) TransformBegin() {
// TransformScaleX scales the width of the following text, drawings and images.
// scaleWd is the percentage scaling factor. (x, y) is center of scaling.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformScaleX(scaleWd, x, y float64) {
f.TransformScale(scaleWd, 100, x, y)
}
@@ -36,6 +36,8 @@ func (f *Fpdf) TransformScaleX(scaleWd, x, y float64) {
// TransformScaleY scales the height of the following text, drawings and
// images. scaleHt is the percentage scaling factor. (x, y) is center of
// scaling.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformScaleY(scaleHt, x, y float64) {
f.TransformScale(100, scaleHt, x, y)
}
@@ -43,6 +45,8 @@ func (f *Fpdf) TransformScaleY(scaleHt, x, y float64) {
// TransformScaleXY uniformly scales the width and height of the following
// text, drawings and images. s is the percentage scaling factor for both width
// and height. (x, y) is center of scaling.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformScaleXY(s, x, y float64) {
f.TransformScale(s, s, x, y)
}
@@ -50,6 +54,8 @@ func (f *Fpdf) TransformScaleXY(s, x, y float64) {
// TransformScale generally scales the following text, drawings and images.
// scaleWd and scaleHt are the percentage scaling factors for width and height.
// (x, y) is center of scaling.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformScale(scaleWd, scaleHt, x, y float64) {
if scaleWd == 0 || scaleHt == 0 {
f.err = fmt.Errorf("scale factor cannot be zero")
@@ -65,18 +71,24 @@ func (f *Fpdf) TransformScale(scaleWd, scaleHt, x, y float64) {
// TransformMirrorHorizontal horizontally mirrors the following text, drawings
// and images. x is the axis of reflection.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformMirrorHorizontal(x float64) {
f.TransformScale(-100, 100, x, f.y)
}
// TransformMirrorVertical vertically mirrors the following text, drawings and
// images. y is the axis of reflection.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformMirrorVertical(y float64) {
f.TransformScale(100, -100, f.x, y)
}
// TransformMirrorPoint symmetrically mirrors the following text, drawings and
// images on the point specified by (x, y).
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformMirrorPoint(x, y float64) {
f.TransformScale(-100, -100, x, y)
}
@@ -85,6 +97,8 @@ func (f *Fpdf) TransformMirrorPoint(x, y float64) {
// images on the line defined by angle and the point (x, y). angles is
// specified in degrees and measured counter-clockwise from the 3 o'clock
// position.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformMirrorLine(angle, x, y float64) {
f.TransformScale(-100, 100, x, y)
f.TransformRotate(-2*(angle-90), x, y)
@@ -92,18 +106,24 @@ func (f *Fpdf) TransformMirrorLine(angle, x, y float64) {
// TransformTranslateX moves the following text, drawings and images
// horizontally by the amount specified by tx.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformTranslateX(tx float64) {
f.TransformTranslate(tx, 0)
}
// TransformTranslateY moves the following text, drawings and images vertically
// by the amount specified by ty.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformTranslateY(ty float64) {
f.TransformTranslate(0, ty)
}
// TransformTranslate moves the following text, drawings and images
// horizontally and vertically by the amounts specified by tx and ty.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformTranslate(tx, ty float64) {
f.Transform(TransformMatrix{1, 0, 0, 1, tx * f.k, -ty * f.k})
}
@@ -111,6 +131,8 @@ func (f *Fpdf) TransformTranslate(tx, ty float64) {
// TransformRotate rotates the following text, drawings and images around the
// center point (x, y). angle is specified in degrees and measured
// counter-clockwise from the 3 o'clock position.
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformRotate(angle, x, y float64) {
y = (f.h - y) * f.k
x *= f.k
@@ -128,6 +150,8 @@ func (f *Fpdf) TransformRotate(angle, x, y float64) {
// TransformSkewX horizontally skews the following text, drawings and images
// keeping the point (x, y) stationary. angleX ranges from -90 degrees (skew to
// the left) to 90 degrees (skew to the right).
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformSkewX(angleX, x, y float64) {
f.TransformSkew(angleX, 0, x, y)
}
@@ -135,6 +159,8 @@ func (f *Fpdf) TransformSkewX(angleX, x, y float64) {
// TransformSkewY vertically skews the following text, drawings and images
// keeping the point (x, y) stationary. angleY ranges from -90 degrees (skew to
// the bottom) to 90 degrees (skew to the top).
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformSkewY(angleY, x, y float64) {
f.TransformSkew(0, angleY, x, y)
}
@@ -143,6 +169,8 @@ func (f *Fpdf) TransformSkewY(angleY, x, y float64) {
// keeping the point (x, y) stationary. angleX ranges from -90 degrees (skew to
// the left) to 90 degrees (skew to the right). angleY ranges from -90 degrees
// (skew to the bottom) to 90 degrees (skew to the top).
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformSkew(angleX, angleY, x, y float64) {
if angleX <= -90 || angleX >= 90 || angleY <= -90 || angleY >= 90 {
f.err = fmt.Errorf("skew values must be between -90° and 90°")
@@ -173,6 +201,8 @@ func (f *Fpdf) Transform(tm TransformMatrix) {
}
// TransformEnd applies a transformation that was begun with a call to TransformBegin().
+//
+// The TransformBegin() example demonstrates this method.
func (f *Fpdf) TransformEnd() {
if f.transformNest > 0 {
f.transformNest--