本文整理汇总了Golang中github.com/google/gxui.Canvas类的典型用法代码示例。如果您正苦于以下问题:Golang Canvas类的具体用法?Golang Canvas怎么用?Golang Canvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Canvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Paint
// mixin.List overrides
func (l *List) Paint(c gxui.Canvas) {
l.List.Paint(c)
if l.HasFocus() {
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)
}
}
示例2: 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))
}
}
示例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))
}
示例4: 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)
}
示例5: 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()
}
示例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)
}
}
示例7: 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)
}
}
示例8: 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()
}
}
示例9: 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)
}
示例10: 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,
})
c.DrawRunes(f, runes, offsets, t.textbox.textColor)
}
示例11: PaintBorders
func (t *CodeEditorLine) PaintBorders(c gxui.Canvas, info CodeEditorLinePaintInfo) {
start, _ := info.LineSpan.Span()
offsets := info.GlyphOffsets
for _, l := range t.ce.layers {
if l != nil && l.BorderColor() != nil {
color := *l.BorderColor()
interval.Visit(l.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)
})
}
}
}
示例12: draw
func draw(p Pendulum, canvas gxui.Canvas, x, y int) {
attachment := math.Point{X: ANIMATION_WIDTH/2 + x, Y: y}
phi := p.GetPhi()
ball := math.Point{X: x + ANIMATION_WIDTH/2 + math.Round(float32(l*omath.Sin(phi))), Y: y + math.Round(float32(l*omath.Cos(phi)))}
line := gxui.Polygon{gxui.PolygonVertex{attachment, 0}, gxui.PolygonVertex{ball, 0}}
canvas.DrawLines(line, gxui.DefaultPen)
m := math.Point{int(BALL_RADIUS), int(BALL_RADIUS)}
rect := math.Rect{ball.Sub(m), ball.Add(m)}
canvas.DrawRoundedRect(rect, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, gxui.TransparentPen, gxui.CreateBrush(gxui.Yellow))
}
示例13: Paint
// parts.DrawPaint overrides
func (l *Label) Paint(c gxui.Canvas) {
r := l.outer.Size().Rect()
t := l.text
if !l.multiline {
t = strings.Replace(t, "\n", " ", -1)
}
runes := []rune(t)
offsets := l.font.Layout(&gxui.TextBlock{
Runes: runes,
AlignRect: r,
H: l.horizontalAlignment,
V: l.verticalAlignment,
})
c.DrawRunes(l.font, runes, offsets, l.color)
}
示例14: drawStar
func drawStar(canvas gxui.Canvas, center math.Point, radius, rotation float32, points int) {
p := make(gxui.Polygon, points*2)
for i := 0; i < points*2; i++ {
frac := float32(i) / float32(points*2)
α := frac*math.TwoPi + rotation
r := []float32{radius, radius / 2}[i&1]
p[i] = gxui.PolygonVertex{
Position: math.Point{
X: center.X + int(r*math.Cosf(α)),
Y: center.Y + int(r*math.Sinf(α)),
},
RoundedRadius: []float32{0, 50}[i&1],
}
}
canvas.DrawPolygon(p, gxui.CreatePen(3, gxui.Red), gxui.CreateBrush(gxui.Yellow))
}
示例15: PaintBackgroundSpans
func (t *CodeEditorLine) PaintBackgroundSpans(c gxui.Canvas, info CodeEditorLinePaintInfo) {
start, _ := info.LineSpan.Span()
offsets := info.GlyphOffsets
remaining := interval.IntDataList{info.LineSpan}
for _, l := range t.ce.layers {
if l != nil && l.BackgroundColor() != nil {
color := *l.BackgroundColor()
for _, span := range l.Spans().Overlaps(info.LineSpan) {
interval.Visit(&remaining, span, 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.TransparentPen, gxui.Brush{Color: color})
})
interval.Remove(&remaining, span)
}
}
}
}