gofmt on package
This commit is contained in:
parent
873e6bfa2b
commit
b0cb20d244
5 changed files with 108 additions and 111 deletions
|
@ -11,8 +11,8 @@ import (
|
|||
|
||||
"image"
|
||||
"image/png"
|
||||
//"draw2d"
|
||||
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
"draw2d"
|
||||
//"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ import (
|
|||
"exp/draw/x11"
|
||||
"image"
|
||||
"math"
|
||||
//"draw2d"
|
||||
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
"draw2d"
|
||||
//"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
)
|
||||
|
||||
func main() {
|
||||
window, err := x11.NewWindow()
|
||||
if(err != nil) {
|
||||
if err != nil {
|
||||
fmt.Printf("Cannot open an x11 window\n")
|
||||
return
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func main() {
|
|||
gc.SetStrokeColor(image.Black)
|
||||
gc.SetFillColor(image.White)
|
||||
gc.Clear()
|
||||
for i := 0.0 ; i < 360; i = i + 10 {// Go from 0 to 360 degrees in 10 degree steps
|
||||
for i := 0.0; i < 360; i = i + 10 { // Go from 0 to 360 degrees in 10 degree steps
|
||||
gc.BeginPath() // Start a new path
|
||||
gc.Save() // Keep rotations temporary
|
||||
gc.MoveTo(144, 144)
|
||||
|
@ -41,15 +41,15 @@ func main() {
|
|||
|
||||
switch evt := (<-window.EventChan()).(type) {
|
||||
case draw.KeyEvent:
|
||||
if(evt.Key == 'q') {
|
||||
if evt.Key == 'q' {
|
||||
window.Close()
|
||||
}
|
||||
case draw.MouseEvent:
|
||||
if(evt.Buttons & 1 != 0) {
|
||||
if(nbclick % 2 == 0) {
|
||||
gc.MoveTo(float(evt.Loc.X),float(evt.Loc.Y))
|
||||
if evt.Buttons&1 != 0 {
|
||||
if nbclick%2 == 0 {
|
||||
gc.MoveTo(float(evt.Loc.X), float(evt.Loc.Y))
|
||||
} else {
|
||||
gc.LineTo(float(evt.Loc.X),float(evt.Loc.Y))
|
||||
gc.LineTo(float(evt.Loc.X), float(evt.Loc.Y))
|
||||
gc.Stroke()
|
||||
window.FlushImage()
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"math"
|
||||
"image"
|
||||
"image/png"
|
||||
//"draw2d"
|
||||
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
"draw2d"
|
||||
//"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -64,12 +64,12 @@ func saveToPngFile(TestName string, m image.Image) {
|
|||
func android(gc *draw2d.GraphicContext, x, y float) {
|
||||
gc.SetLineCap(draw2d.RoundCap)
|
||||
gc.SetLineWidth(5)
|
||||
gc.ArcTo(x+80, y+70, 50, 50, 180 * (math.Pi/180), 360 * (math.Pi/180)) // head
|
||||
gc.ArcTo(x+80, y+70, 50, 50, 180*(math.Pi/180), 360*(math.Pi/180)) // head
|
||||
gc.FillStroke()
|
||||
gc.MoveTo(x+60, y+25)
|
||||
gc.LineTo(x+50, y+10)
|
||||
gc.MoveTo(x+100, y+25)
|
||||
gc.LineTo( x+110, y+10)
|
||||
gc.LineTo(x+110, y+10)
|
||||
gc.Stroke()
|
||||
draw2d.Circle(gc, x+60, y+45, 5) // left eye
|
||||
gc.FillStroke()
|
||||
|
@ -90,7 +90,6 @@ func android(gc *draw2d.GraphicContext, x, y float) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
func main() {
|
||||
i, gc := initGc(width, height)
|
||||
gc.SetFillColor(image.RGBAColor{0xff, 0x44, 0x44, 0xff})
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"math"
|
||||
"image"
|
||||
"image/png"
|
||||
//"draw2d"
|
||||
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
"draw2d"
|
||||
//"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -68,7 +68,7 @@ func saveToPngFile(TestName string, m image.Image) {
|
|||
*/
|
||||
func TestPath() {
|
||||
i, gc := initGc(w, h)
|
||||
gc.Translate(10,10)
|
||||
gc.Translate(10, 10)
|
||||
gc.MoveTo(0.0, 0.0)
|
||||
gc.LineTo(100.0, 00.0)
|
||||
gc.LineTo(100.0, 100.0)
|
||||
|
@ -136,7 +136,6 @@ func TestDrawArcNegative() {
|
|||
gc.SetFillColor(image.RGBAColor{255, 0x33, 0x33, 0x80})
|
||||
gc.SetLineWidth(6)
|
||||
|
||||
|
||||
gc.MoveTo(xc, yc)
|
||||
gc.LineTo(xc+cos(startAngle)*radiusX, yc+sin(startAngle)*radiusY)
|
||||
gc.MoveTo(xc, yc)
|
||||
|
@ -405,20 +404,20 @@ func TestLineJoin() {
|
|||
func TestBubble() {
|
||||
i, gc := initGc(w, h)
|
||||
gc.BeginPath()
|
||||
gc.MoveTo(75,25)
|
||||
gc.QuadCurveTo(25,25,25,62.5)
|
||||
gc.QuadCurveTo(25,100,50,100)
|
||||
gc.QuadCurveTo(50,120,30,125)
|
||||
gc.QuadCurveTo(60,120,65,100)
|
||||
gc.QuadCurveTo(125,100,125,62.5)
|
||||
gc.QuadCurveTo(125,25,75,25)
|
||||
gc.MoveTo(75, 25)
|
||||
gc.QuadCurveTo(25, 25, 25, 62.5)
|
||||
gc.QuadCurveTo(25, 100, 50, 100)
|
||||
gc.QuadCurveTo(50, 120, 30, 125)
|
||||
gc.QuadCurveTo(60, 120, 65, 100)
|
||||
gc.QuadCurveTo(125, 100, 125, 62.5)
|
||||
gc.QuadCurveTo(125, 25, 75, 25)
|
||||
gc.Stroke()
|
||||
saveToPngFile("TestBubble", i)
|
||||
}
|
||||
|
||||
func TestStar() {
|
||||
i, gc := initGc(w, h)
|
||||
for i := 0.0 ; i < 360; i = i + 10 {// Go from 0 to 360 degrees in 10 degree steps
|
||||
for i := 0.0; i < 360; i = i + 10 { // Go from 0 to 360 degrees in 10 degree steps
|
||||
gc.Save()
|
||||
gc.SetLineWidth(5) // Keep rotations temporary
|
||||
gc.Translate(144, 144)
|
||||
|
@ -437,22 +436,22 @@ func TestTransform() {
|
|||
gc.Save()
|
||||
gc.Translate(40, 40) // Set origin to (40, 40)
|
||||
gc.BeginPath()
|
||||
gc.MoveTo(0,0)
|
||||
gc.RLineTo(72,0)
|
||||
gc.MoveTo(0, 0)
|
||||
gc.RLineTo(72, 0)
|
||||
gc.RLineTo(0, 72)
|
||||
gc.RLineTo(-72,0)
|
||||
gc.RLineTo(-72, 0)
|
||||
gc.Close()
|
||||
gc.Stroke()
|
||||
gc.Restore()
|
||||
|
||||
gc.Save()
|
||||
gc.Translate(100, 150) // Translate origin to (100, 150)
|
||||
gc.Rotate(30* (math.Pi / 180.0)) // Rotate counter-clockwise by 30 degrees
|
||||
gc.Rotate(30 * (math.Pi / 180.0)) // Rotate counter-clockwise by 30 degrees
|
||||
gc.BeginPath()
|
||||
gc.MoveTo(0,0)
|
||||
gc.RLineTo(72,0)
|
||||
gc.MoveTo(0, 0)
|
||||
gc.RLineTo(72, 0)
|
||||
gc.RLineTo(0, 72)
|
||||
gc.RLineTo(-72,0)
|
||||
gc.RLineTo(-72, 0)
|
||||
gc.Close() // Draw box...
|
||||
gc.Stroke()
|
||||
gc.Restore()
|
||||
|
@ -461,23 +460,23 @@ func TestTransform() {
|
|||
gc.Translate(40, 300) // Translate to (40, 300)
|
||||
gc.Scale(0.5, 1) // Reduce x coord by 1/2, y coord left alone
|
||||
gc.BeginPath()
|
||||
gc.MoveTo(0,0)
|
||||
gc.RLineTo(72,0)
|
||||
gc.MoveTo(0, 0)
|
||||
gc.RLineTo(72, 0)
|
||||
gc.RLineTo(0, 72)
|
||||
gc.RLineTo(-72,0)
|
||||
gc.RLineTo(-72, 0)
|
||||
gc.Close() // Draw box...
|
||||
gc.Stroke()
|
||||
gc.Restore()
|
||||
|
||||
gc.Save()
|
||||
gc.Translate(300, 300) // Set origin to (300, 300)
|
||||
gc.Rotate(45* (math.Pi / 180.0)) // Rotate coordinates by 45 degrees
|
||||
gc.Rotate(45 * (math.Pi / 180.0)) // Rotate coordinates by 45 degrees
|
||||
gc.Scale(0.5, 1) // Scale coordinates
|
||||
gc.BeginPath()
|
||||
gc.MoveTo(0,0)
|
||||
gc.RLineTo(72,0)
|
||||
gc.MoveTo(0, 0)
|
||||
gc.RLineTo(72, 0)
|
||||
gc.RLineTo(0, 72)
|
||||
gc.RLineTo(-72,0)
|
||||
gc.RLineTo(-72, 0)
|
||||
gc.Close() // Draw box
|
||||
gc.Stroke()
|
||||
gc.Restore()
|
||||
|
@ -488,8 +487,8 @@ func TestTransform() {
|
|||
func TestPathTransform() {
|
||||
i, gc := initGc(800, 600)
|
||||
gc.SetLineWidth(20)
|
||||
gc.Scale(1,5)
|
||||
gc.ArcTo(200, 50, 50, 50, 0, math.Pi * 2)
|
||||
gc.Scale(1, 5)
|
||||
gc.ArcTo(200, 50, 50, 50, 0, math.Pi*2)
|
||||
gc.Stroke()
|
||||
saveToPngFile("TestPathTransform", i)
|
||||
}
|
||||
|
@ -501,7 +500,7 @@ func TestFillString() {
|
|||
gc.FillStroke()
|
||||
gc.SetFontSize(18)
|
||||
gc.MoveTo(10, 52)
|
||||
gc.SetFontData(draw2d.FontData{"luxi", draw2d.FontFamilyMono, draw2d.FontStyleBold|draw2d.FontStyleItalic})
|
||||
gc.SetFontData(draw2d.FontData{"luxi", draw2d.FontFamilyMono, draw2d.FontStyleBold | draw2d.FontStyleItalic})
|
||||
width := gc.FillString("cou")
|
||||
fmt.Printf("width: %f\n", width)
|
||||
gc.RMoveTo(width+1, 0)
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
|
||||
"image"
|
||||
"image/png"
|
||||
//"draw2d"
|
||||
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
"draw2d"
|
||||
//"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -75,9 +75,9 @@ func gordon(gc *draw2d.GraphicContext, x, y, w, h float) {
|
|||
gc.Close()
|
||||
gc.SetFillColor(brb)
|
||||
gc.Fill()
|
||||
draw2d.RoundRect(gc, x, y+h, x+ w, y+h+h, 10, 10)
|
||||
draw2d.RoundRect(gc, x, y+h, x+w, y+h+h, 10, 10)
|
||||
gc.Fill()
|
||||
draw2d.Circle(gc,x, y+h, w/12) // left ear
|
||||
draw2d.Circle(gc, x, y+h, w/12) // left ear
|
||||
gc.SetFillColor(brf)
|
||||
gc.Fill()
|
||||
draw2d.Circle(gc, x, y+h, w/12-10)
|
||||
|
@ -94,7 +94,7 @@ func gordon(gc *draw2d.GraphicContext, x, y, w, h float) {
|
|||
draw2d.Circle(gc, x+w/3, y+h23, w/9) // left eye
|
||||
gc.SetFillColor(wf)
|
||||
gc.Fill()
|
||||
draw2d.Circle(gc, x+w/3+10, y+h23, w / 10 - 10)
|
||||
draw2d.Circle(gc, x+w/3+10, y+h23, w/10-10)
|
||||
gc.SetFillColor(blf)
|
||||
gc.Fill()
|
||||
draw2d.Circle(gc, x+w/3+15, y+h23, 5)
|
||||
|
@ -103,7 +103,7 @@ func gordon(gc *draw2d.GraphicContext, x, y, w, h float) {
|
|||
|
||||
draw2d.Circle(gc, x+w-w/3, y+h23, w/9) // right eye
|
||||
gc.Fill()
|
||||
draw2d.Circle(gc, x+w-w/3+10, y+h23, w / 10 - 10)
|
||||
draw2d.Circle(gc, x+w-w/3+10, y+h23, w/10-10)
|
||||
gc.SetFillColor(blf)
|
||||
gc.Fill()
|
||||
draw2d.Circle(gc, x+w-(w/3)+15, y+h23, 5)
|
||||
|
@ -111,12 +111,11 @@ func gordon(gc *draw2d.GraphicContext, x, y, w, h float) {
|
|||
gc.Fill()
|
||||
|
||||
gc.SetFillColor(wf)
|
||||
draw2d.RoundRect(gc, x+w/2-w/8, y+h+30, x+w/2-w/8 + w/8, y+h+30 + w/6, 5, 5) // left tooth
|
||||
draw2d.RoundRect(gc, x+w/2-w/8, y+h+30, x+w/2-w/8+w/8, y+h+30+w/6, 5, 5) // left tooth
|
||||
gc.Fill()
|
||||
draw2d.RoundRect(gc, x+w/2, y+h+30, x+w/2+w/8, y+h+30+w/6, 5, 5) // right tooth
|
||||
gc.Fill()
|
||||
|
||||
|
||||
draw2d.Ellipse(gc, x+(w/2), y+h+30, w/6, w/12) // snout
|
||||
gc.SetFillColor(nf)
|
||||
gc.Fill()
|
||||
|
|
Loading…
Reference in a new issue