示例#1
0
文件: aw-util.go 项目: xormplus/ui-1
func DrawDefaultElement(x, y, w, h float64, bg color.Color, ctx vg.Context) {

	// Shadow
	ctx.BeginPath()
	ctx.StrokeColor(color.RGBA{100, 100, 100, 100})
	ctx.RoundedRect(x, y, w, h, 30)
	ctx.StrokeWidth(1)
	ctx.Stroke()
	ctx.FillPaint(ctx.BoxGradient(x, y, w, h, h*.5, h, bg, bg))
	ctx.Fill()
}
示例#2
0
文件: line.go 项目: xormplus/ui-1
func (self *LineChart) drawSeries(x, y, w, h float64, ctx vg.Context) {
	// Boundries
	baseline := y + h
	_, max, count := self.Model.Limits()
	horIncr := w / (count - 1)
	vratio := (h - 1) / max
	for _, s := range self.Model.Series() {
		c1 := CloneColor(s.Color)
		c1.A = 150
		ctx.StrokeColor(c1)
		ctx.StrokeWidth(s.StrokeWidth)
		ctx.BeginPath()
		for i, f := range s.Data {
			if i == 0 {
				ctx.MoveTo(x+float64(i)*horIncr, baseline-(f*vratio))
			} else {
				ctx.LineTo(x+float64(i)*horIncr, baseline-(f*vratio))
			}
		}
		ctx.Stroke()

		if self.Fill {
			ctx.BeginPath()
			// ctx.MoveTo(x, baseline)
			c2 := CloneColor(s.Color)
			c2.A = 200
			ctx.FillColor(c2)
			for i, f := range s.Data {
				if i == 0 {
					ctx.MoveTo(x+float64(i)*horIncr, baseline-(f*vratio))
				}

				ctx.LineTo(x+float64(i)*horIncr, baseline-(f*vratio))

				if i == len(s.Data)-1 {
					ctx.LineTo(x+float64(i)*horIncr, baseline)
					ctx.LineTo(x, baseline)
					ctx.MoveTo(x, baseline-(s.Data[0]*vratio))
					break
				}
			}
			ctx.Fill()
		}
	}
}
示例#3
0
文件: element.go 项目: xormplus/ui-1
func (self *Element) Draw(ctx vg.Context) {
	x, y, w, h := self.Bounds()
	x, y = self.Clamp(x, y)

	// draw background
	c := CloneColor(self.ActiveBackground)
	bg := ctx.BoxGradient(x, y, w, h, h, h, c, c)

	ctx.BeginPath()
	ctx.RoundedRect(x, y, w, h, self.CornerRadius)
	ctx.FillPaint(bg)
	ctx.Fill()
	ctx.StrokeWidth(self.BorderWidth)
	ctx.StrokeColor(c.Lighten(-0.5))
	ctx.Stroke()

	if self.DrawCB != nil {
		self.DrawCB(ctx)
	}
}