Skip to content

Commit

Permalink
all: gofmt -s
Browse files Browse the repository at this point in the history
  • Loading branch information
ajstarks committed May 11, 2015
1 parent 04db656 commit 2ffe73c
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 51 deletions.
1 change: 0 additions & 1 deletion android/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"fmt"
"os"
Expand Down
1 change: 0 additions & 1 deletion bubtrail/bubtrail.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"flag"
"fmt"
Expand Down
1 change: 0 additions & 1 deletion codepic/codepic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"bufio"
"encoding/xml"
Expand Down
1 change: 0 additions & 1 deletion colortab/colortab.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"bufio"
"flag"
Expand Down
1 change: 0 additions & 1 deletion f50/f50.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"encoding/xml"
"fmt"
Expand Down
1 change: 0 additions & 1 deletion flower/flower.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"flag"
"fmt"
Expand Down
3 changes: 1 addition & 2 deletions fontcompare/fontcompare.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// fontcompare: compare two fonts
// fontcompare: compare two fonts
// +build !appengine

package main


import (
"fmt"
"os"
Expand Down
1 change: 0 additions & 1 deletion funnel/funnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"os"

Expand Down
1 change: 0 additions & 1 deletion gradient/gradient.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"os"
"strconv"
Expand Down
5 changes: 2 additions & 3 deletions html5logo/html5logo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

package main


import (
"github.com/ajstarks/svgo"
"os"
)

func main() {
// HTML5 logo data from
// "Understanding and Optimizing Web Graphics", Session 508,
// HTML5 logo data from
// "Understanding and Optimizing Web Graphics", Session 508,
// Dean Jackson, Apple WWDC 2011
//
// Draggable elements via Jeff Schiller's dragsvg Javascript library
Expand Down
1 change: 0 additions & 1 deletion imfade/imfade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"fmt"
"os"
Expand Down
1 change: 1 addition & 0 deletions lewitt/lewitt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// +build !appengine

package main

//
// A six-inch (15 cm) grid covering the wall.
// Within each square, not straight lines from side to side, using
Expand Down
1 change: 0 additions & 1 deletion marker/marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"github.com/ajstarks/svgo"
"os"
Expand Down
4 changes: 2 additions & 2 deletions pattern/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
package main

import (
"github.com/ajstarks/svgo"
"fmt"
"github.com/ajstarks/svgo"
"os"
)

Expand All @@ -13,7 +13,7 @@ func main() {
pct := 5
pw, ph := (w*pct)/100, (h*pct)/100
canvas.Start(w, h)

// define the pattern
canvas.Def()
canvas.Pattern("hatch", 0, 0, pw, ph, "user")
Expand Down
110 changes: 110 additions & 0 deletions picserv/index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package main

const (
index = `<html>
<head>
<title>pic256</title>
<style type="text/css">
body {font-family:Helvetica,Arial,Calibri,sans-serif; margin-left: 5%;}
img {padding-right: 1em;}
h1 { font-size: 250%;}
h2 { font-size: 150%; color:rgb(100,100,100);}
h3 { font-size: 120%; color:rgb(120,120,120);}
figure {
font-family:Inconsolata,Courier,monospace;
margin-left:0em; display:
inline-block;
text-align: center;
font-size:120%;
color: rgb(120,120,120)
}
</style>
</head>
<body>
<h1>Pic256</h1>
<h2>Programmed pictures in a 256x256 square</h2>
<h2>Defaults</h2>
<figure><img width="256" height="256" src="http://localhost:1958/rotext/"/><figcaption>rotext</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/flower/"/><figcaption>flower</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/cube/"/><figcaption>cube</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/funnel/"/><figcaption>funnel</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rshape/"/><figcaption>rshape</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/lewitt/"/><figcaption>lewitt</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/mondrian/"/><figcaption>mondrian</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/face/"/><figcaption>face</figcaption></figure>
<h2>Variations</h2>
<h3>rotext</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/rotext/?char=a"/><figcaption>char=a</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rotext/?char=b&ti=40"/><figcaption>char=b&ti=40</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rotext/?char=c&ti=60"/><figcaption>char=c&ti=60</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rotext/?char=i&ti=90&font=Courier"/><figcaption>char=d&ti=90&font=Courier</figcaption></figure>
</p>
<h3>flower</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/flower/?petals=10&n=100"/><figcaption>petals=10&n=100</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/flower/?petals=15&n=50"/><figcaption>petals=15&n=50</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/flower/?petals=20&n=20"/><figcaption>petals=30&n=20</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/flower/?petals=30&n=10"/><figcaption>petals=30&n=10</figcaption></figure>
</p>
<h3>cube</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/cube/?y=80&row=1"/><figcaption>y=80&row=1</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/cube/?y=50&row=2"/><figcaption>y=50&row=2</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/cube/?row=3"/><figcaption>&row=3</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/cube/?y=0&row=4"/><figcaption>y=0&row=4</figcaption></figure>
</p>
<h3>funnel</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/funnel/?step=10"/><figcaption>step=10</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/funnel/?step=15"/><figcaption>step=15</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/funnel/?step=25"/><figcaption>step=25</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/funnel/?step=25&bg=white&fg=black"/><figcaption>step=25&bg=white&fg=black</figcaption></figure>
</p>
<h3>rshape</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/rshape/?shape=c"/><figcaption>shape=c</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rshape/?shape=r"/><figcaption>shape=r</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rshape/?same=f"/><figcaption>same=f</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/rshape/?shape=r&same=t"/><figcaption>shape=r&same=t</figcaption></figure>
</p>
<h3>lewitt</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/lewitt/?pen=1&lines=20"/><figcaption>pen=1&lines=20</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/lewitt/?pen=2&lines=30"/><figcaption>pen=2&lines=30</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/lewitt/?pen=3&lines=40"/><figcaption>pen=3&lines=40</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/lewitt/?pen=5&?lines=100"/><figcaption>pen=5&?lines=100</figcaption></figure>
</p>
<h3>mondrian</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/mondrian/?random=true"/><figcaption>random=true</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/mondrian/?random=t"/><figcaption>random=t</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/mondrian/?random=1"/><figcaption>random=1</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/mondrian/?random=f"/><figcaption>random=f</figcaption></figure>
</p>
<h3>face</h3>
<p>
<figure><img width="256" height="256" src="http://localhost:1958/face/?mood=happy&glance=u"/><figcaption>mood=happy&glance=u</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/face/?mood=neutral&glance=d"/><figcaption>mood=neutral&glance=d</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/face/?mood=sad&glance=l"/><figcaption>mood=sad&glance=l</figcaption></figure>
<figure><img width="256" height="256" src="http://localhost:1958/face/?mood=happy&glance=r"/><figcaption>mood=happy&glance=r</figcaption></figure>
</p>
</body>
</html>
`
)
40 changes: 20 additions & 20 deletions skewabc/skewabc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
package main

import (
"fmt"
"os"
"fmt"
"os"

"github.com/ajstarks/svgo"
"github.com/ajstarks/svgo"
)

var (
g = svg.New(os.Stdout)
width = 500
height = 500
g = svg.New(os.Stdout)
width = 500
height = 500
)

func sky(x, y, w, h int, a float64, s string) {
g.Gstyle(fmt.Sprintf("font-family:sans-serif;font-size:%dpx;text-anchor:middle", w/2))
g.SkewY(a)
g.Rect(x, y, w, h, `fill:black; fill-opacity:0.3`)
g.Text(x+w/2, y+h/2, s, `fill:white;baseline-shift:-33%`)
g.Gend()
g.Gend()
g.Gstyle(fmt.Sprintf("font-family:sans-serif;font-size:%dpx;text-anchor:middle", w/2))
g.SkewY(a)
g.Rect(x, y, w, h, `fill:black; fill-opacity:0.3`)
g.Text(x+w/2, y+h/2, s, `fill:white;baseline-shift:-33%`)
g.Gend()
g.Gend()
}

func main() {
g.Start(width, height)
g.Title("Skew")
g.Rect(0, 0, width, height, "fill:white")
g.Grid(0, 0, width, height, 50, "stroke:lightblue")
sky(100, 100, 100, 100, 30, "A")
sky(200, 332, 100, 100, -30, "B")
sky(300, -15, 100, 100, 30, "C")
g.End()
g.Start(width, height)
g.Title("Skew")
g.Rect(0, 0, width, height, "fill:white")
g.Grid(0, 0, width, height, 50, "stroke:lightblue")
sky(100, 100, 100, 100, 30, "A")
sky(200, 332, 100, 100, -30, "B")
sky(300, -15, 100, 100, 30, "C")
g.End()
}
5 changes: 2 additions & 3 deletions svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const (
<!-- Generated by SVGo -->
<svg`
svginitfmt = `%s width="%d%s" height="%d%s"`
svgns = `
svgns = `
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">`
vbfmt = `viewBox="%d %d %d %d"`
vbfmt = `viewBox="%d %d %d %d"`

emptyclose = "/>\n"
)
Expand Down Expand Up @@ -117,7 +117,6 @@ func (svg *SVG) StartviewUnit(w, h int, unit string, minx, miny, vw, vh int) {
svg.Startunit(w, h, unit, fmt.Sprintf(vbfmt, minx, miny, vw, vh))
}


// Startraw begins the SVG document, passing arbitrary attributes
func (svg *SVG) Startraw(ns ...string) {
svg.printf(svgtop)
Expand Down
8 changes: 4 additions & 4 deletions svgdef/svgdef.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const (
var (
canvas = svg.New(os.Stdout)
grayfill = canvas.RGB(220, 220, 220)
oc1 = svg.Offcolor{Offset:0, Color:"white", Opacity:1.0}
oc2 = svg.Offcolor{Offset:25, Color:"lightblue", Opacity:1.0}
oc3 = svg.Offcolor{Offset:75, Color:"blue", Opacity:1.0}
oc4 = svg.Offcolor{Offset:100, Color:objcolor, Opacity:1.0}
oc1 = svg.Offcolor{Offset: 0, Color: "white", Opacity: 1.0}
oc2 = svg.Offcolor{Offset: 25, Color: "lightblue", Opacity: 1.0}
oc3 = svg.Offcolor{Offset: 75, Color: "blue", Opacity: 1.0}
oc4 = svg.Offcolor{Offset: 100, Color: objcolor, Opacity: 1.0}
ga = []svg.Offcolor{oc1, oc2, oc3, oc4}
)

Expand Down
8 changes: 4 additions & 4 deletions svgplay/svgplay.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// svgplay: sketch with SVGo, (derived from the old misc/goplay), except:
// (1) only listen on localhost, (default port 1999)
// (2) always render html,
// (2) always render html,
// (3) SVGo default code,
// (4) invoke the compiler and linker directly
package main
Expand Down Expand Up @@ -44,7 +44,7 @@ func main() {
log.Fatal(http.ListenAndServe("127.0.0.1:"+*httpListen, nil))
}

// FrontPage is an HTTP handler that renders the svgoplay interface.
// FrontPage is an HTTP handler that renders the svgoplay interface.
// If a filename is supplied in the path component of the URI,
// its contents will be put in the interface's text area.
// Otherwise, the default "hello, world" program is displayed.
Expand Down Expand Up @@ -113,7 +113,7 @@ func compile(req *http.Request) (out []byte, err error) {
return
}

// build and link target.go, creating target
// build and link target.go, creating target
out, err = run("", compiler, "-I", pkgdir, "-o", obj, src)
defer os.Remove(obj)
if err != nil {
Expand All @@ -136,7 +136,7 @@ func compileError(w http.ResponseWriter, out []byte, err error) {
if out != nil {
elines := bytes.Split(out, []byte{'\n'})
for _, l := range elines {
i := bytes.Index(l, []byte{':'} )
i := bytes.Index(l, []byte{':'})
output.Execute(w, l[i+1:])
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion svgplot/svgplot.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
ticfmt = "stroke:rgb(200,200,200);stroke-width:1px"
labelfmt = ticfmt + ";text-anchor:end;fill:black"
textfmt = "stroke:none;baseline-shift:-33.3%"
smallint = -(1 << 30)
smallint = -(1 << 30)
)

// init initializes command flags and sets default options
Expand Down
2 changes: 1 addition & 1 deletion svgrid/svgrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func placepic(x, y int, filename string) (int, int) {
// read the width and height, including any units
// if there are errors use 10 as a default
nw, _ := fmt.Sscanf(s.Width, "%d%s", &width, &wunit)
if nw < 1 {
if nw < 1 {
width = 10
}
nh, _ := fmt.Sscanf(s.Height, "%d%s", &height, &hunit)
Expand Down
1 change: 0 additions & 1 deletion websvg/websvg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package main


import (
"flag"
"log"
Expand Down

0 comments on commit 2ffe73c

Please sign in to comment.