本文整理汇总了Golang中code/google/com/p/draw2d/draw2d.GraphicContext类的典型用法代码示例。如果您正苦于以下问题:Golang GraphicContext类的具体用法?Golang GraphicContext怎么用?Golang GraphicContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GraphicContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: draw
func (i *Image) draw(gc draw2d.GraphicContext) {
ib := i.config.Image.Bounds()
s := ib.Size()
w := float64(s.X)
h := float64(s.Y)
sx := i.Size.X / w
sy := i.Size.Y / h
// uik.Report(i.Size, sx, sy)
gc.Scale(sx, sy)
gc.DrawImage(i.config.Image)
}
示例2: draw
func (b *Button) draw(gc draw2d.GraphicContext) {
gc.Clear()
gc.SetStrokeColor(color.Black)
if b.pressed {
gc.SetFillColor(color.RGBA{150, 150, 150, 255})
} else {
gc.SetFillColor(color.White)
}
safeRect(gc, geom.Coord{0, 0}, b.Size)
gc.FillStroke()
}
示例3: draw
func (l *Label) draw(gc draw2d.GraphicContext) {
// uik.Report(l.ID, "Label.draw()")
//gc.Clear()
// gc.SetFillColor(color.RGBA{A: 1})
// safeRect(gc, geom.Coord{0, 0}, l.Size)
// gc.Fill()
tw := float64(l.tbuf.Bounds().Max.X - l.tbuf.Bounds().Min.X)
th := float64(l.tbuf.Bounds().Max.Y - l.tbuf.Bounds().Min.Y)
gc.Translate((l.Size.X-tw)/2, (l.Size.Y-th)/2)
gc.DrawImage(l.tbuf)
}
示例4: draw
func (l *KeyGrab) draw(gc draw2d.GraphicContext) {
gc.Clear()
if l.HasKeyFocus {
gc.SetFillColor(color.RGBA{150, 150, 150, 255})
safeRect(gc, geom.Coord{0, 0}, l.Size)
gc.FillStroke()
}
tw := float64(l.kbuf.Bounds().Max.X - l.kbuf.Bounds().Min.X)
th := float64(l.kbuf.Bounds().Max.Y - l.kbuf.Bounds().Min.Y)
gc.Translate((l.Size.X-tw)/2, (l.Size.Y-th)/2)
gc.DrawImage(l.kbuf)
}
示例5: arrow
func arrow(path draw2d.GraphicContext, x, y, w, h float64, up bool) {
var m float64 = 1
if up {
m = 3
}
path.MoveTo(x+w/2, y)
path.LineTo(x+w, y+(h/4)*m)
path.LineTo(x+w/2, y+h)
path.LineTo(x, y+(h/4)*m)
path.Close()
}
示例6: rect
func rect(path draw2d.GraphicContext, x1, x2, y1, y2 float64) {
path.MoveTo(x1, y1)
path.LineTo(x2, y1)
path.LineTo(x2, y2)
path.LineTo(x1, y2)
path.Close()
}
示例7: Paint
func (this ArrowButton) Paint(gc draw2d.GraphicContext) {
gc.SetFillColor(color.RGBA{0x22, 0x22, 0x22, 0xFF})
rect(gc, float64(this.X), float64(this.X+this.W), float64(this.Y), float64(this.Y+this.H))
gc.Fill()
gc.SetFillColor(color.RGBA{0xFF, 0x33, 0x33, 0xFF})
arrow(gc, float64(this.X), float64(this.Y), float64(this.W), float64(this.H), this.Up)
gc.Fill()
}
示例8: lineCoordSeq
func lineCoordSeq(ctxt draw2d.GraphicContext, cs *geos.CoordSeq, scale func(x, y float64) (float64, float64)) {
n := cs.Size()
if n == 0 {
return
}
// XXX: interface like sql.Scan() and .Error()
getX := getOrd(cs, (*geos.CoordSeq).GetX)
getY := getOrd(cs, (*geos.CoordSeq).GetY)
x, y := getX(0), getY(0)
ctxt.MoveTo(scale(x, y))
for i := 1; i < n; i++ {
x, y = getX(i), getY(i)
x, y = scale(x, y)
ctxt.LineTo(x, y)
}
}
示例9: drawPolygon
func drawPolygon(ctxt draw2d.GraphicContext, g *geos.Geometry, fillColor color.Color, strokeColor color.Color, width float64, scale func(x, y float64) (float64, float64)) {
ctxt.SetFillColor(fillColor)
ctxt.SetStrokeColor(strokeColor)
ctxt.SetLineWidth(width)
// exterior ring
ring := geos.Must(g.ExteriorRing())
cs, err := ring.coordSeq()
if err != nil {
log.Fatal(err)
}
lineCoordSeq(ctxt, cs, scale)
ctxt.FillStroke()
// interior rings...
}
示例10: ClearPaint
func ClearPaint(gc draw2d.GraphicContext) {
if true {
gc.Clear()
gc.SetFillColor(color.RGBA{155, 0, 0, 255})
gc.Fill()
}
}
示例11: draw
func (l *Label) draw(gc draw2d.GraphicContext) {
gc.Clear()
tw := float64(l.tbuf.Bounds().Max.X - l.tbuf.Bounds().Min.X)
th := float64(l.tbuf.Bounds().Max.Y - l.tbuf.Bounds().Min.Y)
gc.Translate((l.Size.X-tw)/2, (l.Size.Y-th)/2)
gc.DrawImage(l.tbuf)
}
示例12: drawPoint
func drawPoint(ctxt draw2d.GraphicContext, g *geos.Geometry, c color.Color, radius float64, scale func(x, y float64) (float64, float64)) {
if c != nil {
ctxt.SetFillColor(c)
}
x, err := g.X()
if err != nil {
log.Fatal(err)
}
y, err := g.Y()
if err != nil {
log.Fatal(err)
}
x, y = scale(x, y)
ctxt.MoveTo(x, y)
ctxt.ArcTo(x, y, radius, radius, 0, 2*math.Pi)
ctxt.Fill()
}
示例13: drawLine
func drawLine(ctxt draw2d.GraphicContext, g *geos.Geometry, c color.Color, width float64, scale func(x, y float64) (float64, float64)) {
if c != nil {
ctxt.SetStrokeColor(c)
}
if width != 0.0 {
ctxt.SetLineWidth(width)
}
// XXX: should get a [] of points
cs, err := g.coordSeq()
if err != nil {
log.Fatal(err)
}
lineCoordSeq(ctxt, cs, scale)
ctxt.Stroke()
}
示例14: drawInfoarea
func drawInfoarea(gc draw2d.GraphicContext) {
gc.SetFontSize(20)
gc.SetFillColor(color.RGBA{0xFF, 0xFF, 0xFF, 0xFF})
gc.MoveTo(BAR_START_X, IA_START_Y)
gc.FillString(curTime.Add(Day*-7).Format(DATE_FORMAT) + " - " + curTime.Format(DATE_FORMAT))
}
示例15: safeRect
func safeRect(path draw2d.GraphicContext, min, max Coord) {
x1, y1 := min.X, min.Y
x2, y2 := max.X, max.Y
x, y := path.LastPoint()
path.MoveTo(x1, y1)
path.LineTo(x2, y1)
path.LineTo(x2, y2)
path.LineTo(x1, y2)
path.Close()
path.MoveTo(x, y)
}