Exemplo n.º 1
0
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()
}
Exemplo n.º 2
0
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)
	}
}
Exemplo n.º 3
0
func (self *Text) Draw(ctx vg.Context) {
	x, y, w, h := self.Bounds()
	self.lastContext = &ctx
	ctx.Scissor(x, y, w, h)
	ctx.BeginPath()
	ctx.RoundedRect(x, y, w, h, self.CornerRadius)
	ctx.FillColor(self.Background)
	ctx.Fill()
	ctx.FillColor(self.Foreground)

	self.forEachDrawnToken(x, y, w, h,
		func(i int, x, y, lineHeight float64, bounds *ui.Rectangle, ctx *vg.Context) {
			ctx.Text(x, y, self.tokens[i])
		},
	)

	// for i := 0; i < len(self.selections); i++ {
	// 	s := self.selections[i]
	// }

	ctx.ResetScissor()
}