From 1c6df583206f7e838858898d43debd4fb989d2b4 Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Fri, 15 Jul 2016 13:40:24 -0700 Subject: [PATCH] some report card feedback. --- drawing/flattener.go | 6 ++++++ drawing/matrix.go | 11 ++++++----- testserver/main.go | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drawing/flattener.go b/drawing/flattener.go index e3fef9a..61bfd07 100644 --- a/drawing/flattener.go +++ b/drawing/flattener.go @@ -64,27 +64,33 @@ func Flatten(path *Path, flattener Flattener, scale float64) { flattener.End() } +// SegmentedPath is a path of disparate point sectinos. type SegmentedPath struct { Points []float64 } +// MoveTo implements the path interface. func (p *SegmentedPath) MoveTo(x, y float64) { p.Points = append(p.Points, x, y) // TODO need to mark this point as moveto } +// LineTo implements the path interface. func (p *SegmentedPath) LineTo(x, y float64) { p.Points = append(p.Points, x, y) } +// LineJoin implements the path interface. func (p *SegmentedPath) LineJoin() { // TODO need to mark the current point as linejoin } +// Close implements the path interface. func (p *SegmentedPath) Close() { // TODO Close } +// End implements the path interface. func (p *SegmentedPath) End() { // Nothing to do } diff --git a/drawing/matrix.go b/drawing/matrix.go index b9a4128..32e0ef4 100644 --- a/drawing/matrix.go +++ b/drawing/matrix.go @@ -40,7 +40,7 @@ func minMax(x, y float64) (min, max float64) { return x, y } -// Transform applies the transformation matrix to the rectangle represented by the min and the max point of the rectangle +// TransformRectangle applies the transformation matrix to the rectangle represented by the min and the max point of the rectangle func (tr Matrix) TransformRectangle(x0, y0, x2, y2 float64) (nx0, ny0, nx2, ny2 float64) { points := []float64{x0, y0, x2, y0, x2, y2, x0, y2} tr.Transform(points) @@ -129,6 +129,7 @@ func (tr *Matrix) Inverse() { tr[5] = (tr1*tr4 - tr0*tr5) / d } +// Copy copies the matrix. func (tr Matrix) Copy() Matrix { var result Matrix copy(result[:], tr[:]) @@ -174,12 +175,12 @@ func (tr *Matrix) Rotate(angle float64) { tr[3] = t3 } -// GetTranslation +// GetTranslation gets the matrix traslation. func (tr Matrix) GetTranslation() (x, y float64) { return tr[4], tr[5] } -// GetScaling +// GetScaling gets the matrix scaling. func (tr Matrix) GetScaling() (x, y float64) { return tr[0], tr[3] } @@ -194,9 +195,9 @@ func (tr Matrix) GetScale() float64 { // ******************** Testing ******************** // Equals tests if a two transformation are equal. A tolerance is applied when comparing matrix elements. -func (tr1 Matrix) Equals(tr2 Matrix) bool { +func (tr Matrix) Equals(tr2 Matrix) bool { for i := 0; i < 6; i = i + 1 { - if !fequals(tr1[i], tr2[i]) { + if !fequals(tr[i], tr2[i]) { return false } } diff --git a/testserver/main.go b/testserver/main.go index cd0e6a9..de7c50c 100644 --- a/testserver/main.go +++ b/testserver/main.go @@ -215,6 +215,9 @@ func boxHandler(rc *web.RequestContext) web.ControllerResult { rc.Response.Header().Set("Content-Type", "image/png") buffer := bytes.NewBuffer([]byte{}) err = r.Save(buffer) + if err != nil { + return rc.API().InternalError(err) + } return rc.Raw(buffer.Bytes()) }