From 6b9ea45e96f5928beb21d03436525cb4ae6a2e2e Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Fri, 9 Jun 2017 18:13:05 +0200
Subject: [PATCH] minor, mostly stylistic, changes

---
 geometry.go       | 10 ++++------
 imdraw/imdraw.go  | 14 ++++++++++----
 pixelgl/canvas.go | 14 ++++++--------
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/geometry.go b/geometry.go
index 928c9c5..13a574d 100644
--- a/geometry.go
+++ b/geometry.go
@@ -263,7 +263,7 @@ func (r Rect) Union(s Rect) Rect {
 // Layout is:
 // [0] [2] [4]
 // [1] [3] [5]
-//  0   0   1  [implicit row]
+//  0   0   1  (implicit row)
 type Matrix [6]float64
 
 // IM stands for identity matrix. Does nothing, no transformation.
@@ -332,11 +332,9 @@ func (m Matrix) Project(u Vec) Vec {
 
 // Unproject does the inverse operation to Project.
 //
-// It turns out that multiplying a vector by the inverse matrix of m
-// can be nearly-accomplished by subtracting the translate part of the
-// matrix and multplying by the inverse of the top-left 2x2 matrix,
-// and the inverse of a 2x2 matrix is simple enough to just be
-// inlined in the computation.
+// It turns out that multiplying a vector by the inverse matrix of m can be nearly-accomplished by
+// subtracting the translate part of the matrix and multplying by the inverse of the top-left 2x2
+// matrix, and the inverse of a 2x2 matrix is simple enough to just be inlined in the computation.
 //
 // Time complexity is O(1).
 func (m Matrix) Unproject(u Vec) Vec {
diff --git a/imdraw/imdraw.go b/imdraw/imdraw.go
index e5a8c95..f7ce769 100644
--- a/imdraw/imdraw.go
+++ b/imdraw/imdraw.go
@@ -260,8 +260,8 @@ func (imd *IMDraw) getAndClearPoints() []point {
 	// use one of the existing pools so we don't reallocate as often
 	if len(imd.pool) > 0 {
 		pos := len(imd.pool) - 1
-		imd.points = imd.pool[pos]
-		imd.pool = imd.pool[0:pos]
+		imd.points = imd.pool[pos][:0]
+		imd.pool = imd.pool[:pos]
 	} else {
 		imd.points = nil
 	}
@@ -306,7 +306,7 @@ func (imd *IMDraw) fillRectangle() {
 			in:  (a.in + b.in) / 2,
 		}
 
-		for k, p := range []point{a, b, c, a, b, d} {
+		for k, p := range [...]point{a, b, c, a, b, d} {
 			(*imd.tri)[j+k].Position = p.pos
 			(*imd.tri)[j+k].Color = p.col
 			(*imd.tri)[j+k].Picture = p.pic
@@ -316,6 +316,7 @@ func (imd *IMDraw) fillRectangle() {
 
 	imd.applyMatrixAndMask(off)
 	imd.batch.Dirty()
+
 	imd.restorePoints(points)
 }
 
@@ -339,6 +340,7 @@ func (imd *IMDraw) outlineRectangle(thickness float64) {
 		imd.pushPt(pixel.V(b.pos.X, a.pos.Y), mid)
 		imd.polyline(thickness, true)
 	}
+
 	imd.restorePoints(points)
 }
 
@@ -354,7 +356,7 @@ func (imd *IMDraw) fillPolygon() {
 	imd.tri.SetLen(imd.tri.Len() + 3*(len(points)-2))
 
 	for i, j := 1, off; i+1 < len(points); i, j = i+1, j+3 {
-		for k, p := range []int{0, i, i + 1} {
+		for k, p := range [...]int{0, i, i + 1} {
 			tri := &(*imd.tri)[j+k]
 			tri.Position = points[p].pos
 			tri.Color = points[p].col
@@ -365,6 +367,7 @@ func (imd *IMDraw) fillPolygon() {
 
 	imd.applyMatrixAndMask(off)
 	imd.batch.Dirty()
+
 	imd.restorePoints(points)
 }
 
@@ -407,6 +410,7 @@ func (imd *IMDraw) fillEllipseArc(radius pixel.Vec, low, high float64) {
 		imd.applyMatrixAndMask(off)
 		imd.batch.Dirty()
 	}
+
 	imd.restorePoints(points)
 }
 
@@ -506,6 +510,7 @@ func (imd *IMDraw) outlineEllipseArc(radius pixel.Vec, low, high, thickness floa
 			}
 		}
 	}
+
 	imd.restorePoints(points)
 }
 
@@ -617,5 +622,6 @@ func (imd *IMDraw) polyline(thickness float64, closed bool) {
 			imd.fillEllipseArc(pixel.V(thickness/2, thickness/2), normal.Angle(), normal.Angle()-math.Pi)
 		}
 	}
+
 	imd.restorePoints(points)
 }
diff --git a/pixelgl/canvas.go b/pixelgl/canvas.go
index b7b5cfc..b8e4057 100644
--- a/pixelgl/canvas.go
+++ b/pixelgl/canvas.go
@@ -90,15 +90,13 @@ func (c *Canvas) MakePicture(p pixel.Picture) pixel.TargetPicture {
 }
 
 // SetMatrix sets a Matrix that every point will be projected by.
-// pixel.Matrix is 3x2 with an implicit 0, 0, 1 row after it. So
-// [0] [2] [4]    [0] [3] [6]
-// [1] [3] [5] => [1] [4] [7]
-//  0   0   1      0   0   1
-// since all matrix ops are affine, the last row never changes,
-// and we don't need to copy it
-//
 func (c *Canvas) SetMatrix(m pixel.Matrix) {
-	for i, j := range [6]int{ 0, 1, 3, 4, 6, 7} {
+	// pixel.Matrix is 3x2 with an implicit 0, 0, 1 row after it. So
+	// [0] [2] [4]    [0] [3] [6]
+	// [1] [3] [5] => [1] [4] [7]
+	//  0   0   1      0   0   1
+	// since all matrix ops are affine, the last row never changes, and we don't need to copy it
+	for i, j := range [...]int{0, 1, 3, 4, 6, 7} {
 		c.mat[j] = float32(m[i])
 	}
 }
-- 
GitLab