當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gxui.Canvas類代碼示例

本文整理匯總了Golang中github.com/nelsam/gxui.Canvas的典型用法代碼示例。如果您正苦於以下問題:Golang Canvas類的具體用法?Golang Canvas怎麽用?Golang Canvas使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Canvas類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Paint

// parts.DrawPaint overrides
func (b *SplitterBar) Paint(c gxui.Canvas) {
	r := b.outer.Size().Rect()
	c.DrawRect(r, gxui.CreateBrush(b.backgroundColor))
	if b.foregroundColor != b.backgroundColor {
		c.DrawRect(r.ContractI(1), gxui.CreateBrush(b.foregroundColor))
	}
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:8,代碼來源:splitter_bar.go

示例2: Paint

func (d *treeButton) Paint(canvas gxui.Canvas) {
	style := d.Style()

	rect := d.Size().Rect()
	poly := gxui.Polygon{
		{Position: math.Point{
			X: rect.Min.X,
			Y: rect.Max.Y,
		}},
		{Position: math.Point{
			X: rect.Min.X,
			Y: rect.Min.Y,
		}},
		{Position: math.Point{
			X: rect.Max.X,
			Y: rect.Min.Y,
		}},
		{Position: math.Point{
			X: rect.Max.X,
			Y: rect.Max.Y,
		}},
	}
	canvas.DrawPolygon(poly, gxui.TransparentPen, style.Brush)
	d.PaintChildren.Paint(canvas)
}
開發者ID:nelsam,項目名稱:vidar,代碼行數:25,代碼來源:tree_button.go

示例3: drawMoon

func drawMoon(canvas gxui.Canvas, center math.Point, radius float32) {
	c := 40
	p := make(gxui.Polygon, c*2)
	for i := 0; i < c; i++ {
		frac := float32(i) / float32(c)
		α := math.Lerpf(math.Pi*1.2, math.Pi*-0.2, frac)
		p[i] = gxui.PolygonVertex{
			Position: math.Point{
				X: center.X + int(radius*math.Sinf(α)),
				Y: center.Y + int(radius*math.Cosf(α)),
			},
			RoundedRadius: 0,
		}
	}
	for i := 0; i < c; i++ {
		frac := float32(i) / float32(c)
		α := math.Lerpf(math.Pi*-0.2, math.Pi*1.2, frac)
		r := math.Lerpf(radius, radius*0.5, math.Sinf(frac*math.Pi))
		p[i+c] = gxui.PolygonVertex{
			Position: math.Point{
				X: center.X + int(r*math.Sinf(α)),
				Y: center.Y + int(r*math.Cosf(α)),
			},
			RoundedRadius: 0,
		}
	}
	canvas.DrawPolygon(p, gxui.CreatePen(3, gxui.Gray80), gxui.CreateBrush(gxui.Gray40))
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:28,代碼來源:main.go

示例4: Paint

// mixin.List overrides
func (l *DropDownList) Paint(c gxui.Canvas) {
	l.DropDownList.Paint(c)
	if l.HasFocus() || l.ListShowing() {
		r := l.Size().Rect().ContractI(1)
		c.DrawRoundedRect(r, 3.0, 3.0, 3.0, 3.0, l.theme.FocusedStyle.Pen, l.theme.FocusedStyle.Brush)
	}
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:8,代碼來源:drop_down_list.go

示例5: Paint

func (b *menuButton) Paint(canvas gxui.Canvas) {
	style := b.Style()
	if l := b.Label(); l != nil {
		l.SetColor(style.FontColor)
	}

	rect := b.Size().Rect()
	poly := gxui.Polygon{
		{Position: math.Point{
			X: rect.Min.X,
			Y: rect.Max.Y,
		}},
		{Position: math.Point{
			X: rect.Min.X,
			Y: rect.Min.Y,
		}},
		{Position: math.Point{
			X: rect.Max.X,
			Y: rect.Min.Y,
		}},
		{Position: math.Point{
			X: rect.Max.X,
			Y: rect.Max.Y,
		}},
	}
	canvas.DrawPolygon(poly, gxui.TransparentPen, style.Brush)
	b.PaintChildren.Paint(canvas)
	canvas.DrawLines(poly, style.Pen)
}
開發者ID:nelsam,項目名稱:vidar,代碼行數:29,代碼來源:menu.go

示例6: Paint

// mixins.CodeEditor overrides
func (t *CodeEditor) Paint(c gxui.Canvas) {
	t.CodeEditor.Paint(c)

	if t.HasFocus() {
		r := t.Size().Rect()
		c.DrawRoundedRect(r, 3, 3, 3, 3, t.theme.FocusedStyle.Pen, t.theme.FocusedStyle.Brush)
	}
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:9,代碼來源:code_editor.go

示例7: Paint

// mixins.CodeEditor overrides
func (e *editor) Paint(c gxui.Canvas) {
	e.CodeEditor.Paint(c)

	if e.HasFocus() {
		r := e.Size().Rect()
		c.DrawRoundedRect(r, 3, 3, 3, 3, e.theme.FocusedStyle.Pen, e.theme.FocusedStyle.Brush)
	}
}
開發者ID:gitter-badger,項目名稱:vidar,代碼行數:9,代碼來源:editor.go

示例8: PaintProgress

func (b *ProgressBar) PaintProgress(c gxui.Canvas, r math.Rect, frac float32) {
	r.Max.X = math.Lerp(r.Min.X, r.Max.X, frac)
	c.DrawRect(r, gxui.CreateBrush(gxui.Gray50))
	c.Push()
	c.AddClip(r)
	c.DrawCanvas(b.chevrons, math.Point{X: b.scroll})
	c.Pop()
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:8,代碼來源:progress_bar.go

示例9: Paint

func (p *PanelHolder) Paint(c gxui.Canvas) {
	panel := p.SelectedPanel()
	if panel != nil {
		bounds := p.Children().Find(panel).Bounds()
		c.DrawRoundedRect(bounds, 0.0, 0.0, 3.0, 3.0, p.theme.PanelBackgroundStyle.Pen, p.theme.PanelBackgroundStyle.Brush)
	}
	p.PanelHolder.Paint(c)
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:8,代碼來源:panel_holder.go

示例10: Paint

// mixins.TextBox overrides
func (t *TextBox) Paint(c gxui.Canvas) {
	t.TextBox.Paint(c)

	if t.HasFocus() {
		r := t.Size().Rect()
		s := t.theme.FocusedStyle
		c.DrawRoundedRect(r, 3, 3, 3, 3, s.Pen, s.Brush)
	}
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:10,代碼來源:textbox.go

示例11: Paint

func (f *FSLocator) Paint(c gxui.Canvas) {
	f.LinearLayout.Paint(c)

	if f.HasFocus() {
		r := f.Size().Rect()
		s := f.theme.FocusedStyle
		c.DrawRoundedRect(r, 3, 3, 3, 3, s.Pen, s.Brush)
	}
}
開發者ID:nelsam,項目名稱:vidar,代碼行數:9,代碼來源:fslocator.go

示例12: Paint

func (i *Image) Paint(c gxui.Canvas) {
	r := i.outer.Size().Rect()
	i.PaintBackground(c, r)
	switch {
	case i.texture != nil:
		c.DrawTexture(i.texture, i.calculateDrawRect())
	case i.canvas != nil:
		c.DrawCanvas(i.canvas, math.ZeroPoint)
	}
	i.PaintBorder(c, r)
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:11,代碼來源:image.go

示例13: SetCanvas

func (i *Image) SetCanvas(canvas gxui.Canvas) {
	if !canvas.IsComplete() {
		panic("SetCanvas() called with an incomplete canvas")
	}

	if i.canvas != canvas {
		i.canvas = canvas
		i.texture = nil
		i.outer.Relayout()
	}
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:11,代碼來源:image.go

示例14: PaintText

func (t *DefaultTextBoxLine) PaintText(c gxui.Canvas) {
	runes := []rune(t.textbox.controller.Line(t.lineIndex))
	f := t.textbox.font
	offsets := f.Layout(&gxui.TextBlock{
		Runes:     runes,
		AlignRect: t.Size().Rect().OffsetX(t.caretWidth),
		H:         gxui.AlignLeft,
		V:         gxui.AlignBottom,
	})
	for i, offset := range offsets {
		offsets[i] = offset.AddX(-t.offset)
	}
	c.DrawRunes(f, runes, offsets, t.textbox.textColor)
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:14,代碼來源:default_textbox_line.go

示例15: PaintBorders

func (l *CodeEditorLine) PaintBorders(c gxui.Canvas, info CodeEditorLinePaintInfo) {
	start, _ := info.LineSpan.Span()
	offsets := info.GlyphOffsets
	for _, layer := range l.ce.layers {
		if layer != nil && layer.BorderColor() != nil {
			color := *layer.BorderColor()
			interval.Visit(layer.Spans(), info.LineSpan, func(vs, ve uint64, _ int) {
				s, e := vs-start, ve-start
				r := math.CreateRect(offsets[s].X, 0, offsets[e-1].X+info.GlyphWidth, info.LineHeight)
				c.DrawRoundedRect(r, 3, 3, 3, 3, gxui.CreatePen(0.5, color), gxui.TransparentBrush)
			})
		}
	}
}
開發者ID:nelsam,項目名稱:gxui,代碼行數:14,代碼來源:code_editor_line.go


注:本文中的github.com/nelsam/gxui.Canvas類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。