draw2dkit
This commit is contained in:
parent
9012e5e580
commit
94ef483cbd
2 changed files with 8 additions and 52 deletions
|
@ -19,32 +19,32 @@ func Droid(gc draw2d.GraphicContext, x, y float64) {
|
|||
gc.Stroke()
|
||||
|
||||
// left eye
|
||||
draw2d.Circle(gc, x+60, y+45, 5)
|
||||
Circle(gc, x+60, y+45, 5)
|
||||
gc.FillStroke()
|
||||
|
||||
// right eye
|
||||
draw2d.Circle(gc, x+100, y+45, 5)
|
||||
Circle(gc, x+100, y+45, 5)
|
||||
gc.FillStroke()
|
||||
|
||||
// body
|
||||
draw2d.RoundedRectangle(gc, x+30, y+75, x+30+100, y+75+90, 10, 10)
|
||||
RoundedRectangle(gc, x+30, y+75, x+30+100, y+75+90, 10, 10)
|
||||
gc.FillStroke()
|
||||
draw2d.Rectangle(gc, x+30, y+75, x+30+100, y+75+80)
|
||||
Rectangle(gc, x+30, y+75, x+30+100, y+75+80)
|
||||
gc.FillStroke()
|
||||
|
||||
// left arm
|
||||
draw2d.RoundedRectangle(gc, x+5, y+80, x+5+20, y+80+70, 10, 10)
|
||||
RoundedRectangle(gc, x+5, y+80, x+5+20, y+80+70, 10, 10)
|
||||
gc.FillStroke()
|
||||
|
||||
// right arm
|
||||
draw2d.RoundedRectangle(gc, x+135, y+80, x+135+20, y+80+70, 10, 10)
|
||||
RoundedRectangle(gc, x+135, y+80, x+135+20, y+80+70, 10, 10)
|
||||
gc.FillStroke()
|
||||
|
||||
// left leg
|
||||
draw2d.RoundedRectangle(gc, x+50, y+150, x+50+20, y+150+50, 10, 10)
|
||||
RoundedRectangle(gc, x+50, y+150, x+50+20, y+150+50, 10, 10)
|
||||
gc.FillStroke()
|
||||
|
||||
// right leg
|
||||
draw2d.RoundedRectangle(gc, x+90, y+150, x+90+20, y+150+50, 10, 10)
|
||||
RoundedRectangle(gc, x+90, y+150, x+90+20, y+150+50, 10, 10)
|
||||
gc.FillStroke()
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright 2010 The draw2d Authors. All rights reserved.
|
||||
// created: 13/12/2010 by Laurent Le Goff
|
||||
|
||||
package draw2d
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
// Rectangle draws a rectangle using a PathBuilder
|
||||
func Rectangle(path PathBuilder, x1, y1, x2, y2 float64) {
|
||||
path.MoveTo(x1, y1)
|
||||
path.LineTo(x2, y1)
|
||||
path.LineTo(x2, y2)
|
||||
path.LineTo(x1, y2)
|
||||
path.Close()
|
||||
}
|
||||
|
||||
// RoundedRectangle draws a rounded rectangle using a PathBuilder
|
||||
func RoundedRectangle(path PathBuilder, x1, y1, x2, y2, arcWidth, arcHeight float64) {
|
||||
arcWidth = arcWidth / 2
|
||||
arcHeight = arcHeight / 2
|
||||
path.MoveTo(x1, y1+arcHeight)
|
||||
path.QuadCurveTo(x1, y1, x1+arcWidth, y1)
|
||||
path.LineTo(x2-arcWidth, y1)
|
||||
path.QuadCurveTo(x2, y1, x2, y1+arcHeight)
|
||||
path.LineTo(x2, y2-arcHeight)
|
||||
path.QuadCurveTo(x2, y2, x2-arcWidth, y2)
|
||||
path.LineTo(x1+arcWidth, y2)
|
||||
path.QuadCurveTo(x1, y2, x1, y2-arcHeight)
|
||||
path.Close()
|
||||
}
|
||||
|
||||
// Ellipse draws an ellipse using a PathBuilder
|
||||
func Ellipse(path PathBuilder, cx, cy, rx, ry float64) {
|
||||
path.ArcTo(cx, cy, rx, ry, 0, -math.Pi*2)
|
||||
path.Close()
|
||||
}
|
||||
|
||||
// Circle draws a circle using a PathBuilder
|
||||
func Circle(path PathBuilder, cx, cy, radius float64) {
|
||||
path.ArcTo(cx, cy, radius, radius, 0, -math.Pi*2)
|
||||
path.Close()
|
||||
}
|
Loading…
Reference in a new issue