diff options
| author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:27:16 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:27:16 -0800 |
| commit | 881d6064d23d9da5c7ff368bc7d41d271290deff (patch) | |
| tree | 44d5d948e3f27cc7eff15ec8cd7ee5165d9a7e90 /src/pkg/exp/draw/arith.go | |
| parent | d9dfea3ebd51cea89fef8afc6b2377c2958b24f1 (diff) | |
| download | golang-881d6064d23d9da5c7ff368bc7d41d271290deff.tar.gz | |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
2nd set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/179067
Diffstat (limited to 'src/pkg/exp/draw/arith.go')
| -rw-r--r-- | src/pkg/exp/draw/arith.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/pkg/exp/draw/arith.go b/src/pkg/exp/draw/arith.go index 59830bba5..6ed1c4a5a 100644 --- a/src/pkg/exp/draw/arith.go +++ b/src/pkg/exp/draw/arith.go @@ -6,7 +6,7 @@ package draw // A Point is an X, Y coordinate pair. type Point struct { - X, Y int; + X, Y int } // ZP is the zero Point. @@ -14,35 +14,35 @@ var ZP Point // A Rectangle contains the Points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y. type Rectangle struct { - Min, Max Point; + Min, Max Point } // ZR is the zero Rectangle. var ZR Rectangle // Pt is shorthand for Point{X, Y}. -func Pt(X, Y int) Point { return Point{X, Y} } +func Pt(X, Y int) Point { return Point{X, Y} } // Rect is shorthand for Rectangle{Pt(x0, y0), Pt(x1, y1)}. -func Rect(x0, y0, x1, y1 int) Rectangle { return Rectangle{Point{x0, y0}, Point{x1, y1}} } +func Rect(x0, y0, x1, y1 int) Rectangle { return Rectangle{Point{x0, y0}, Point{x1, y1}} } // Rpt is shorthand for Rectangle{min, max}. -func Rpt(min, max Point) Rectangle { return Rectangle{min, max} } +func Rpt(min, max Point) Rectangle { return Rectangle{min, max} } // Add returns the sum of p and q: Pt(p.X+q.X, p.Y+q.Y). -func (p Point) Add(q Point) Point { return Point{p.X + q.X, p.Y + q.Y} } +func (p Point) Add(q Point) Point { return Point{p.X + q.X, p.Y + q.Y} } // Sub returns the difference of p and q: Pt(p.X-q.X, p.Y-q.Y). -func (p Point) Sub(q Point) Point { return Point{p.X - q.X, p.Y - q.Y} } +func (p Point) Sub(q Point) Point { return Point{p.X - q.X, p.Y - q.Y} } // Mul returns p scaled by k: Pt(p.X*k p.Y*k). -func (p Point) Mul(k int) Point { return Point{p.X * k, p.Y * k} } +func (p Point) Mul(k int) Point { return Point{p.X * k, p.Y * k} } // Div returns p divided by k: Pt(p.X/k, p.Y/k). -func (p Point) Div(k int) Point { return Point{p.X / k, p.Y / k} } +func (p Point) Div(k int) Point { return Point{p.X / k, p.Y / k} } // Eq returns true if p and q are equal. -func (p Point) Eq(q Point) bool { return p.X == q.X && p.Y == q.Y } +func (p Point) Eq(q Point) bool { return p.X == q.X && p.Y == q.Y } // Inset returns the rectangle r inset by n: Rect(r.Min.X+n, r.Min.Y+n, r.Max.X-n, r.Max.Y-n). func (r Rectangle) Inset(n int) Rectangle { @@ -50,10 +50,10 @@ func (r Rectangle) Inset(n int) Rectangle { } // Add returns the rectangle r translated by p: Rpt(r.Min.Add(p), r.Max.Add(p)). -func (r Rectangle) Add(p Point) Rectangle { return Rectangle{r.Min.Add(p), r.Max.Add(p)} } +func (r Rectangle) Add(p Point) Rectangle { return Rectangle{r.Min.Add(p), r.Max.Add(p)} } // Sub returns the rectangle r translated by -p: Rpt(r.Min.Sub(p), r.Max.Sub(p)). -func (r Rectangle) Sub(p Point) Rectangle { return Rectangle{r.Min.Sub(p), r.Max.Sub(p)} } +func (r Rectangle) Sub(p Point) Rectangle { return Rectangle{r.Min.Sub(p), r.Max.Sub(p)} } // Canon returns a canonical version of r: the returned rectangle // has Min.X <= Max.X and Min.Y <= Max.Y. @@ -64,7 +64,7 @@ func (r Rectangle) Canon() Rectangle { if r.Max.Y < r.Min.Y { r.Max.Y = r.Min.Y } - return r; + return r } // Overlaps returns true if r and r1 cross; that is, it returns true if they share any point. @@ -74,7 +74,7 @@ func (r Rectangle) Overlaps(r1 Rectangle) bool { } // Empty retruns true if r contains no points. -func (r Rectangle) Empty() bool { return r.Max.X <= r.Min.X || r.Max.Y <= r.Min.Y } +func (r Rectangle) Empty() bool { return r.Max.X <= r.Min.X || r.Max.Y <= r.Min.Y } // InRect returns true if all the points in r are also in r1. func (r Rectangle) In(r1 Rectangle) bool { @@ -85,7 +85,7 @@ func (r Rectangle) In(r1 Rectangle) bool { return false } return r1.Min.X <= r.Min.X && r.Max.X <= r1.Max.X && - r1.Min.Y <= r.Min.Y && r.Max.Y <= r1.Max.Y; + r1.Min.Y <= r.Min.Y && r.Max.Y <= r1.Max.Y } // Combine returns the smallest rectangle containing all points from r and from r1. @@ -108,7 +108,7 @@ func (r Rectangle) Combine(r1 Rectangle) Rectangle { if r.Max.Y < r1.Max.Y { r.Max.Y = r1.Max.Y } - return r; + return r } // Clip returns the largest rectangle containing only points shared by r and r1. @@ -131,11 +131,11 @@ func (r Rectangle) Clip(r1 Rectangle) Rectangle { if r.Max.Y > r1.Max.Y { r.Max.Y = r1.Max.Y } - return r; + return r } // Dx returns the width of the rectangle r: r.Max.X - r.Min.X. -func (r Rectangle) Dx() int { return r.Max.X - r.Min.X } +func (r Rectangle) Dx() int { return r.Max.X - r.Min.X } // Dy returns the width of the rectangle r: r.Max.Y - r.Min.Y. -func (r Rectangle) Dy() int { return r.Max.Y - r.Min.Y } +func (r Rectangle) Dy() int { return r.Max.Y - r.Min.Y } |
