本文整理汇总了Golang中github.com/google/gxui.Canvas类的典型用法代码示例。如果您正苦于以下问题:Golang Canvas类的具体用法?Golang Canvas怎么用?Golang Canvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Canvas类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
}
开发者ID:linux-mac,项目名称:gxui,代码行数:8,代码来源:list.go
示例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))
}
}
开发者ID:liulnn,项目名称:gxui,代码行数:8,代码来源:splitter_bar.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:langxj,项目名称:gxui,代码行数:28,代码来源:main.go
示例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)
}
开发者ID:langxj,项目名称:gxui,代码行数:8,代码来源:panel_holder.go
示例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()
}
开发者ID:linux-mac,项目名称:gxui,代码行数:8,代码来源:progress_bar.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:langxj,项目名称:gxui,代码行数:9,代码来源:code_editor.go
示例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)
}
}
开发者ID:linux-mac,项目名称:gxui,代码行数:10,代码来源:textbox.go
示例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()
}
}
开发者ID:langxj,项目名称:gxui,代码行数:11,代码来源:image.go
示例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)
}
开发者ID:langxj,项目名称:gxui,代码行数:11,代码来源:image.go
示例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)
}
开发者ID:langxj,项目名称:gxui,代码行数:11,代码来源:default_textbox_line.go
示例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)
})
}
}
}
开发者ID:langxj,项目名称:gxui,代码行数:14,代码来源:code_editor_line.go
示例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))
}
开发者ID:jefferyyuan,项目名称:RosettaCodeData,代码行数:14,代码来源:animate-a-pendulum.go
示例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)
}
开发者ID:liulnn,项目名称:gxui,代码行数:17,代码来源:label.go
示例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))
}
开发者ID:langxj,项目名称:gxui,代码行数:16,代码来源:main.go
示例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)
}
}
}
}
开发者ID:langxj,项目名称:gxui,代码行数:18,代码来源:code_editor_line.go
示例16: drawTimeAxis
func drawTimeAxis(canvas gxui.Canvas) {
p := gxui.Polygon{
gxui.PolygonVertex{
Position: math.Point{
X: 0,
Y: 400,
},
RoundedRadius: 0,
},
gxui.PolygonVertex{
Position: math.Point{
X: 400,
Y: 400,
},
RoundedRadius: 0,
},
}
canvas.DrawLines(p, gxui.CreatePen(1.0, gxui.White))
}
开发者ID:canejune,项目名称:sandbox,代码行数:20,代码来源:bview.go
示例17: Paint
func (t *PanelTab) Paint(c gxui.Canvas) {
s := t.Size()
var style Style
switch {
case t.IsMouseDown(gxui.MouseButtonLeft) && t.IsMouseOver():
style = t.theme.TabPressedStyle
case t.IsMouseOver():
style = t.theme.TabOverStyle
default:
style = t.theme.TabDefaultStyle
}
if l := t.Label(); l != nil {
l.SetColor(style.FontColor)
}
c.DrawRoundedRect(s.Rect(), 5.0, 5.0, 0.0, 0.0, style.Pen, style.Brush)
if t.HasFocus() {
style = t.theme.FocusedStyle
r := math.CreateRect(1, 1, s.W-1, s.H-1)
c.DrawRoundedRect(r, 4.0, 4.0, 0.0, 0.0, style.Pen, style.Brush)
}
if t.active {
style = t.theme.TabActiveHighlightStyle
r := math.CreateRect(1, s.H-1, s.W-1, s.H)
c.DrawRect(r, style.Brush)
}
t.Button.Paint(c)
}
开发者ID:liulnn,项目名称:gxui,代码行数:31,代码来源:panel_tab.go
示例18: PaintGlyphs
func (t *CodeEditorLine) PaintGlyphs(c gxui.Canvas, info CodeEditorLinePaintInfo) {
start, _ := info.LineSpan.Span()
runes, offsets, font := info.Runes, info.GlyphOffsets, info.Font
remaining := interval.IntDataList{info.LineSpan}
for _, l := range t.ce.layers {
if l != nil && l.Color() != nil {
color := *l.Color()
for _, span := range l.Spans().Overlaps(info.LineSpan) {
interval.Visit(&remaining, span, func(vs, ve uint64, _ int) {
s, e := vs-start, ve-start
c.DrawRunes(font, runes[s:e], offsets[s:e], color)
})
interval.Remove(&remaining, span)
}
}
}
for _, span := range remaining {
s, e := span.Span()
s, e = s-start, e-start
c.DrawRunes(font, runes[s:e], offsets[s:e], t.ce.textColor)
}
}
开发者ID:langxj,项目名称:gxui,代码行数:22,代码来源:code_editor_line.go
示例19: drawHorizontalLines
func (f Field) drawHorizontalLines(canvas gxui.Canvas) {
for y := f.cellHeight; y < f.height; y += f.cellHeight {
p := make(gxui.Polygon, 2)
p[0] = gxui.PolygonVertex{
Position: math.Point{
X: 0,
Y: y,
},
RoundedRadius: 0,
}
p[1] = gxui.PolygonVertex{
Position: math.Point{
X: f.width,
Y: y,
},
RoundedRadius: 0,
}
canvas.DrawLines(p, gxui.CreatePen(1, gxui.Gray80))
}
}
开发者ID:fesenko,项目名称:snake,代码行数:23,代码来源:field.go
示例20: drawVerticalLines
func (f Field) drawVerticalLines(canvas gxui.Canvas) {
for x := f.cellWidth; x < f.width; x += f.cellWidth {
p := make(gxui.Polygon, 2)
p[0] = gxui.PolygonVertex{
Position: math.Point{
X: x,
Y: 0,
},
RoundedRadius: 0,
}
p[1] = gxui.PolygonVertex{
Position: math.Point{
X: x,
Y: f.height,
},
RoundedRadius: 0,
}
canvas.DrawLines(p, gxui.CreatePen(1, gxui.Gray80))
}
}
开发者ID:fesenko,项目名称:snake,代码行数:23,代码来源:field.go
注:本文中的github.com/google/gxui.Canvas类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论