本文整理汇总了Golang中github.com/shibukawa/nanovgo.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: loadImageDirectory
func loadImageDirectory(ctx *nanovgo.Context, dir string) []nanogui.Image {
var images []nanogui.Image
files, err := ioutil.ReadDir(dir)
if err != nil {
panic(fmt.Sprintf("loadImageDirectory: read error %v\n", err))
}
for _, file := range files {
if file.IsDir() {
continue
}
ext := path.Ext(file.Name())
if ext != ".png" {
continue
}
fullPath := path.Join(dir, file.Name())
img := ctx.CreateImage(fullPath, 0)
if img == 0 {
panic("Could not open image data!")
}
images = append(images, nanogui.Image{
ImageID: img,
Name: fullPath[:len(fullPath)-4],
})
}
return images
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:26,代码来源:sample.go
示例2: PreferredSize
func (i *ImageView) PreferredSize(self Widget, ctx *nanovgo.Context) (int, int) {
if i.image == 0 {
return 0, 0
}
w, h, _ := ctx.ImageSize(i.image)
return w, h
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:7,代码来源:imageview.go
示例3: drawLabel
func drawLabel(ctx *nanovgo.Context, text string, x, y, w, h float32) {
ctx.SetFontSize(18.0)
ctx.SetFontFace("sans")
ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 128))
ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
ctx.Text(x, y+h*0.5, text)
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:9,代码来源:demo.go
示例4: drawEditBox
func drawEditBox(ctx *nanovgo.Context, text string, x, y, w, h float32) {
drawEditBoxBase(ctx, x, y, w, h)
ctx.SetFontSize(20.0)
ctx.SetFontFace("sans")
ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 64))
ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
ctx.Text(x+h*0.3, y+h*0.5, text)
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:10,代码来源:demo.go
示例5: RenderDemo
func RenderDemo(ctx *nanovgo.Context, mx, my, width, height, t float32, blowup bool, data *DemoData) {
drawEyes(ctx, width-250, 50, 150, 100, mx, my, t)
drawParagraph(ctx, width-450, 50, 150, 100, mx, my)
drawGraph(ctx, 0, height/2, width, height/2, t)
drawColorWheel(ctx, width-300, height-300, 250.0, 250.0, t)
// Line joints
drawLines(ctx, 120, height-50, 600, 50, t)
// Line widths
drawWidths(ctx, 10, 50, 30)
// Line caps
drawCaps(ctx, 10, 300, 30)
drawScissor(ctx, 50, height-80, t)
ctx.Save()
defer ctx.Restore()
if blowup {
ctx.Rotate(sinF(t*0.3) * 5.0 / 180.0 * nanovgo.PI)
ctx.Scale(2.0, 2.0)
}
// Widgets
drawWindow(ctx, "Widgets `n Stuff", 50, 50, 300, 400)
var x float32 = 60.0
var y float32 = 95.0
drawSearchBox(ctx, "Search", x, y, 280, 25)
y += 40
drawDropDown(ctx, "Effects", x, y, 280, 28)
popy := y + 14
y += 45
// Form
drawLabel(ctx, "Login", x, y, 280, 20)
y += 25
drawEditBox(ctx, "Email", x, y, 280, 28)
y += 35
drawEditBox(ctx, "Password", x, y, 280, 28)
y += 38
drawCheckBox(ctx, "Remember me", x, y, 140, 28)
drawButton(ctx, IconLOGIN, "Sign in", x+138, y, 140, 28, nanovgo.RGBA(0, 96, 128, 255))
y += 45
// Slider
drawLabel(ctx, "Diameter", x, y, 280, 20)
y += 25
drawEditBoxNum(ctx, "123.00", "px", x+180, y, 100, 28)
drawSlider(ctx, 0.4, x, y, 170, 28)
y += 55
drawButton(ctx, IconTRASH, "Delete", x, y, 160, 28, nanovgo.RGBA(128, 16, 8, 255))
drawButton(ctx, 0, "Cancel", x+170, y, 110, 28, nanovgo.RGBA(0, 0, 0, 0))
// Thumbnails box
drawThumbnails(ctx, 365, popy-30, 160, 300, data.Images, t)
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:59,代码来源:demo.go
示例6: Draw
func (i *ImageView) Draw(self Widget, ctx *nanovgo.Context) {
if i.image == 0 {
return
}
x := float32(i.x)
y := float32(i.y)
ow := float32(i.w)
oh := float32(i.h)
var w, h float32
{
iw, ih, _ := ctx.ImageSize(i.image)
w = float32(iw)
h = float32(ih)
}
if i.policy == ImageSizePolicyFixed {
if ow < w {
h = float32(int(h * ow / w))
w = ow
}
if oh < h {
w = float32(int(w * oh / h))
h = oh
}
} else { // mPolicy == Expand
// expand to width
h = float32(int(h * ow / w))
w = ow
// shrink to height, if necessary
if oh < h {
w = float32(int(w * oh / h))
h = oh
}
}
imgPaint := nanovgo.ImagePattern(x, y, w, h, 0, i.image, 1.0)
ctx.BeginPath()
ctx.Rect(x, y, w, h)
ctx.SetFillPaint(imgPaint)
ctx.Fill()
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:43,代码来源:imageview.go
示例7: loadImageDirectory
func loadImageDirectory(ctx *nanovgo.Context, dir string) []nanogui.Image {
var images []nanogui.Image
files, err := AssetDir("icons")
if err != nil {
panic(err)
}
for _, file := range files {
fullPath := fmt.Sprintf("%s/%s", "icons", file)
img := ctx.CreateImageFromMemory(0, MustAsset(fullPath))
if img == 0 {
panic("Could not open image data!")
}
images = append(images, nanogui.Image{
ImageID: img,
Name: fullPath[:len(fullPath)-4],
})
}
return images
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:19,代码来源:web.go
示例8: PreferredSize
func (t *TextBox) PreferredSize(self Widget, ctx *nanovgo.Context) (int, int) {
sizeH := float32(t.FontSize()) * 1.4
var unitWidth, textWidth float32
ctx.SetFontSize(float32(t.FontSize()))
if t.unitImage > 0 {
w, h, _ := ctx.ImageSize(t.unitImage)
unitHeight := sizeH * 0.4
unitWidth = float32(w) * unitHeight / float32(h)
} else if t.units != "" {
unitWidth, _ = ctx.TextBounds(0, 0, t.units)
}
textWidth, _ = ctx.TextBounds(0, 0, string(t.editingText()))
sizeW := sizeH + textWidth + unitWidth
return int(sizeW), int(sizeH)
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:17,代码来源:textbox.go
示例9: PreferredSize
func (c *CheckBox) PreferredSize(self Widget, ctx *nanovgo.Context) (int, int) {
fw, fh := c.FixedSize()
if fw > 0 || fh > 0 {
return fw, fh
}
fontSize := float32(c.FontSize())
ctx.SetFontSize(fontSize)
ctx.SetFontFace(c.theme.FontNormal)
w, _ := ctx.TextBounds(0, 0, c.caption)
return int(w + 1.7*fontSize), int(fontSize * 1.3)
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:11,代码来源:checkbox.go
示例10: PreferredSize
func (w *Window) PreferredSize(self Widget, ctx *nanovgo.Context) (int, int) {
if w.buttonPanel != nil {
w.buttonPanel.SetVisible(false)
}
width, height := w.WidgetImplement.PreferredSize(self, ctx)
if w.buttonPanel != nil {
w.buttonPanel.SetVisible(true)
}
ctx.SetFontSize(18.0)
ctx.SetFontFace(w.theme.FontBold)
_, bounds := ctx.TextBounds(0, 0, w.title)
return maxI(width, int(bounds[2]-bounds[0])+20), maxI(height, int(bounds[3]-bounds[1]))
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:14,代码来源:window.go
示例11: NewStandardTheme
func NewStandardTheme(ctx *nanovgo.Context) *Theme {
ctx.CreateFontFromMemory("sans", MustAsset("fonts/Roboto-Regular.ttf"), 0)
ctx.CreateFontFromMemory("sans-bold", MustAsset("fonts/Roboto-Bold.ttf"), 0)
ctx.CreateFontFromMemory("icons", MustAsset("fonts/entypo.ttf"), 0)
return &Theme{
StandardFontSize: 16,
ButtonFontSize: 20,
TextBoxFontSize: 20,
WindowCornerRadius: 2,
WindowHeaderHeight: 30,
WindowDropShadowSize: 10,
ButtonCornerRadius: 2,
DropShadow: nanovgo.MONO(0, 128),
Transparent: nanovgo.MONO(0, 0),
BorderDark: nanovgo.MONO(29, 255),
BorderLight: nanovgo.MONO(92, 255),
BorderMedium: nanovgo.MONO(35, 255),
TextColor: nanovgo.MONO(255, 160),
DisabledTextColor: nanovgo.MONO(255, 80),
TextColorShadow: nanovgo.MONO(0, 160),
IconColor: nanovgo.MONO(255, 160),
ButtonGradientTopFocused: nanovgo.MONO(64, 255),
ButtonGradientBotFocused: nanovgo.MONO(48, 255),
ButtonGradientTopUnfocused: nanovgo.MONO(74, 255),
ButtonGradientBotUnfocused: nanovgo.MONO(58, 255),
ButtonGradientTopPushed: nanovgo.MONO(41, 255),
ButtonGradientBotPushed: nanovgo.MONO(29, 255),
WindowFillUnfocused: nanovgo.MONO(43, 230),
WindowFillFocused: nanovgo.MONO(45, 230),
WindowTitleUnfocused: nanovgo.MONO(220, 160),
WindowTitleFocused: nanovgo.MONO(255, 190),
WindowHeaderGradientTop: nanovgo.MONO(74, 255),
WindowHeaderGradientBot: nanovgo.MONO(58, 255),
WindowHeaderSepTop: nanovgo.MONO(92, 255),
WindowHeaderSepBot: nanovgo.MONO(29, 255),
WindowPopup: nanovgo.MONO(50, 255),
WindowPopupTransparent: nanovgo.MONO(50, 0),
FontNormal: "sans",
FontBold: "sans-bold",
FontIcons: "icons",
}
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:48,代码来源:theme.go
示例12: LoadDemo
func LoadDemo(ctx *nanovgo.Context) *demo.DemoData {
d := &demo.DemoData{}
for i := 0; i < 12; i++ {
path := fmt.Sprintf("assets/image%d.jpg", i+1)
d.Images = append(d.Images, ctx.CreateImageFromMemory(0, demo.MustAsset(path)))
if d.Images[i] == 0 {
log.Fatalf("Could not load %s", path)
}
}
d.FontIcons = ctx.CreateFontFromMemory("icons", demo.MustAsset("assets/entypo.ttf"), 0)
if d.FontIcons == -1 {
log.Fatalln("Could not add font icons.")
}
d.FontNormal = ctx.CreateFontFromMemory("sans", demo.MustAsset("assets/Roboto-Regular.ttf"), 0)
if d.FontNormal == -1 {
log.Fatalln("Could not add font italic.")
}
d.FontBold = ctx.CreateFontFromMemory("sans-bold", demo.MustAsset("assets/Roboto-Bold.ttf"), 0)
if d.FontBold == -1 {
log.Fatalln("Could not add font bold.")
}
return d
}
开发者ID:shibukawa,项目名称:nanovgo,代码行数:24,代码来源:web.go
示例13: Draw
func (sf *SpinnerFilter) Draw(self nanogui.Widget, ctx *nanovgo.Context) {
if sf.isActive() {
var py int
fw, fh := sf.Parent().Size()
if window, ok := sf.Parent().(*nanogui.Window); ok {
hh := window.Theme().WindowHeaderHeight
py += hh
fh -= hh
}
sf.SetPosition(0, py)
sf.SetSize(fw, fh)
currentTime := nanogui.GetTime() - sf.startTime
var alpha float32
var showSpinner bool
if sf.state == SpinnerFadeIn {
if currentTime > 1 {
alpha = 0.7
showSpinner = true
} else {
alpha = currentTime * 0.7
}
} else {
if currentTime > 1 {
alpha = 0.7
} else {
alpha = (1.0 - currentTime) * 0.7
}
}
ctx.Save()
ctx.BeginPath()
ctx.SetFillColor(nanovgo.MONOf(0, alpha))
ctx.Rect(0, float32(py), float32(fw), float32(fh))
ctx.Fill()
if showSpinner {
cx := float32(fw / 2)
cy := float32(py + fh/2)
rotation := 2 * math.Pi * float64(currentTime*float32(sf.speed)*float32(sf.num)) / float64(sf.num)
dr := float64(2 * math.Pi / float64(sf.num))
ctx.SetStrokeWidth(sf.lineWidth)
for i := 0; i < sf.num; i++ {
ctx.BeginPath()
ctx.MoveTo(cx+float32(math.Cos(rotation))*sf.c1, cy+float32(math.Sin(rotation))*sf.c1)
ctx.LineTo(cx+float32(math.Cos(rotation))*sf.c2, cy+float32(math.Sin(rotation))*sf.c2)
ctx.SetStrokeColor(nanovgo.MONOf(1.0, float32(i)/float32(sf.num)))
ctx.Stroke()
rotation += dr
}
}
ctx.Restore()
} else {
sf.SetSize(0, 0)
sf.SetVisible(false)
return
}
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:57,代码来源:spinner.go
示例14: Draw
func (p *ProgressBar) Draw(self Widget, ctx *nanovgo.Context) {
px := float32(p.x)
py := float32(p.y)
pw := float32(p.w)
ph := float32(p.h)
p.WidgetImplement.Draw(self, ctx)
paint := nanovgo.BoxGradient(px+1, py+1, pw-2, ph, 3, 4, nanovgo.MONO(0, 32), nanovgo.MONO(0, 92))
ctx.BeginPath()
ctx.RoundedRect(px, py, pw, ph, 3)
ctx.SetFillPaint(paint)
ctx.Fill()
value := clampF(p.value, 0.0, 1.0)
barPos := (pw - 2) * value
barPaint := nanovgo.BoxGradient(px, py, barPos+1.5, ph-1, 3, 4, nanovgo.MONO(220, 100), nanovgo.MONO(128, 100))
ctx.BeginPath()
ctx.RoundedRect(px+1, py+1, barPos, ph-2, 3)
ctx.SetFillPaint(barPaint)
ctx.Fill()
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:20,代码来源:progressbar.go
示例15: Draw
func (c *ColorWheel) Draw(self Widget, ctx *nanovgo.Context) {
c.WidgetImplement.Draw(self, ctx)
if !c.visible {
return
}
x := float32(c.x)
y := float32(c.y)
w := float32(c.w)
h := float32(c.h)
ctx.Save()
defer ctx.Restore()
cx := x + w*0.5
cy := y + h*0.5
r1 := toF(w < h, w, h)*0.5 - 5.0
r0 := r1 * 0.75
aeps := 0.7 / r1 // half a pixel arc length in radians (2pi cancels out).
for i := 0; i < 6; i++ {
a0 := float32(i)/6.0*nanovgo.PI*2.0 - aeps
a1 := float32(i+1)/6.0*nanovgo.PI*2.0 + aeps
ctx.BeginPath()
ctx.Arc(cx, cy, r0, a0, a1, nanovgo.Clockwise)
ctx.Arc(cx, cy, r1, a1, a0, nanovgo.CounterClockwise)
ctx.ClosePath()
sin1, cos1 := sinCosF(a0)
sin2, cos2 := sinCosF(a1)
ax := cx + cos1*(r0+r1)*0.5
ay := cy + sin1*(r0+r1)*0.5
bx := cx + cos2*(r0+r1)*0.5
by := cy + sin2*(r0+r1)*0.5
color1 := nanovgo.HSLA(a0/(nanovgo.PI*2), 1.0, 0.55, 255)
color2 := nanovgo.HSLA(a1/(nanovgo.PI*2), 1.0, 0.55, 255)
paint := nanovgo.LinearGradient(ax, ay, bx, by, color1, color2)
ctx.SetFillPaint(paint)
ctx.Fill()
}
ctx.BeginPath()
ctx.Circle(cx, cy, r0-0.5)
ctx.Circle(cx, cy, r1+0.5)
ctx.SetStrokeColor(nanovgo.MONO(0, 64))
ctx.Stroke()
// Selector
ctx.Save()
defer ctx.Restore()
ctx.Translate(cx, cy)
ctx.Rotate(c.hue * nanovgo.PI * 2)
// Marker on
u := clampF(r1/50, 1.5, 4.0)
ctx.SetStrokeWidth(u)
ctx.BeginPath()
ctx.Rect(r0-1, -2*u, r1-r0+2, 4*u)
ctx.SetStrokeColor(nanovgo.MONO(255, 192))
ctx.Stroke()
paint := nanovgo.BoxGradient(r0-3, -5, r1-r0+6, 10, 2, 4, nanovgo.MONO(0, 128), nanovgo.MONO(0, 0))
ctx.BeginPath()
ctx.Rect(r0-2-10, -4-10, r1-r0+4+20, 8+20)
ctx.Rect(r0-2, -4, r1-r0+4, 8)
ctx.PathWinding(nanovgo.Hole)
ctx.SetFillPaint(paint)
ctx.Fill()
// Center triangle
r := r0 - 6
sin1, cos1 := sinCosF(120.0 / 180.0 * nanovgo.PI)
sin2, cos2 := sinCosF(-120.0 / 180.0 * nanovgo.PI)
ax := cos1 * r
ay := sin1 * r
bx := cos2 * r
by := sin2 * r
ctx.BeginPath()
ctx.MoveTo(r, 0)
ctx.LineTo(ax, ay)
ctx.LineTo(bx, by)
ctx.ClosePath()
triPaint1 := nanovgo.LinearGradient(r, 0, ax, ay, nanovgo.HSL(c.hue, 1.0, 0.5), nanovgo.MONO(255, 255))
ctx.SetFillPaint(triPaint1)
ctx.Fill()
triPaint2 := nanovgo.LinearGradient((r+ax)*0.5, ay*0.5, bx, by, nanovgo.MONO(0, 0), nanovgo.MONO(0, 255))
ctx.SetFillPaint(triPaint2)
ctx.Fill()
// selector circle on triangle
px, py := c.calculatePosition()
ctx.SetStrokeWidth(u)
ctx.BeginPath()
ctx.Circle(px, py, 2*u)
ctx.SetStrokeColor(nanovgo.MONO(255, 192))
ctx.Stroke()
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:97,代码来源:colorwheel.go
示例16: drawLines
func drawLines(ctx *nanovgo.Context, x, y, w, h, t float32) {
var pad float32 = 5.0
s := w/9.0 - pad*2
joins := []nanovgo.LineCap{nanovgo.Miter, nanovgo.Round, nanovgo.Bevel}
caps := []nanovgo.LineCap{nanovgo.Butt, nanovgo.Round, nanovgo.Square}
ctx.Save()
defer ctx.Restore()
pts := []float32{
-s*0.25 + cosF(t*0.3)*s*0.5,
sinF(t*0.3) * s * 0.5,
-s * 0.25,
0,
s * 0.25,
0,
s*0.25 + cosF(-t*0.3)*s*0.5,
sinF(-t*0.3) * s * 0.5,
}
for i, cap := range caps {
for j, join := range joins {
fx := x + s*0.5 + float32(i*3+j)/9.0*w + pad
fy := y - s*0.5 + pad
ctx.SetLineCap(cap)
ctx.SetLineJoin(join)
ctx.SetStrokeWidth(s * 0.3)
ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 160))
ctx.BeginPath()
ctx.MoveTo(fx+pts[0], fy+pts[1])
ctx.LineTo(fx+pts[2], fy+pts[3])
ctx.LineTo(fx+pts[4], fy+pts[5])
ctx.LineTo(fx+pts[6], fy+pts[7])
ctx.Stroke()
ctx.SetLineCap(nanovgo.Butt)
ctx.SetLineJoin(nanovgo.Bevel)
ctx.SetStrokeWidth(1.0)
ctx.SetStrokeColor(nanovgo.RGBA(0, 192, 255, 255))
ctx.BeginPath()
ctx.MoveTo(fx+pts[0], fy+pts[1])
ctx.LineTo(fx+pts[2], fy+pts[3])
ctx.LineTo(fx+pts[4], fy+pts[5])
ctx.LineTo(fx+pts[6], fy+pts[7])
ctx.Stroke()
}
}
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:51,代码来源:demo.go
示例17: Draw
func (i *ImagePanel) Draw(self Widget, ctx *nanovgo.Context) {
cols, _ := i.gridSize()
x := float32(i.x)
y := float32(i.y)
thumbSize := float32(i.thumbSize)
for j, image := range i.images {
pX := x + float32(i.margin+(j%cols)*(i.thumbSize+i.spacing))
pY := y + float32(i.margin+(j/cols)*(i.thumbSize+i.spacing))
imgW, imgH, _ := ctx.ImageSize(image.ImageID)
var iw, ih, ix, iy float32
if imgW < imgH {
iw = thumbSize
ih = iw * float32(imgH) / float32(imgW)
ix = 0
iy = -(ih - thumbSize) * 0.5
} else {
ih = thumbSize
iw = ih * float32(imgH) / float32(imgW)
iy = 0
ix = -(iw - thumbSize) * 0.5
}
imgPaint := nanovgo.ImagePattern(pX+ix, pY+iy, iw, ih, 0, image.ImageID, toF(i.mouseIndex == j, 1.0, 0.7))
ctx.BeginPath()
ctx.RoundedRect(pX, pY, thumbSize, thumbSize, 5)
ctx.SetFillPaint(imgPaint)
ctx.Fill()
shadowPaint := nanovgo.BoxGradient(pX-1, pY, thumbSize+2, thumbSize+2, 5, 3, nanovgo.MONO(0, 128), nanovgo.MONO(0, 0))
ctx.BeginPath()
ctx.Rect(pX-5, pY-5, thumbSize+10, thumbSize+10)
ctx.RoundedRect(pX, pY, thumbSize, thumbSize, 6)
ctx.PathWinding(nanovgo.Hole)
ctx.SetFillPaint(shadowPaint)
ctx.Fill()
ctx.BeginPath()
ctx.RoundedRect(pX+0.5, pY+0.5, thumbSize-1, thumbSize-1, 4-0.5)
ctx.SetStrokeWidth(1.0)
ctx.SetStrokeColor(nanovgo.MONO(255, 80))
ctx.Stroke()
}
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:46,代码来源:imagepanel.go
示例18: drawCaps
func drawCaps(ctx *nanovgo.Context, x, y, width float32) {
caps := []nanovgo.LineCap{nanovgo.Butt, nanovgo.Round, nanovgo.Square}
var lineWidth float32 = 8.0
ctx.Save()
defer ctx.Restore()
ctx.BeginPath()
ctx.Rect(x-lineWidth/2, y, width+lineWidth, 40)
ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 32))
ctx.Fill()
ctx.BeginPath()
ctx.Rect(x, y, width, 40)
ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 32))
ctx.Fill()
ctx.SetStrokeWidth(lineWidth)
for i, cap := range caps {
ctx.SetLineCap(cap)
ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 255))
ctx.BeginPath()
ctx.MoveTo(x, y+float32(i)*10+5)
ctx.LineTo(x+width, y+float32(i)*10+5)
ctx.Stroke()
}
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:28,代码来源:demo.go
示例19: drawWidths
func drawWidths(ctx *nanovgo.Context, x, y, width float32) {
ctx.Save()
defer ctx.Restore()
ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 255))
for i := 0; i < 20; i++ {
w := (float32(i) + 0.5) * 0.1
ctx.SetStrokeWidth(w)
ctx.BeginPath()
ctx.MoveTo(x, y)
ctx.LineTo(x+width, y+width*0.3)
ctx.Stroke()
y += 10
}
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:15,代码来源:demo.go
示例20: Draw
func (g *Graph) Draw(self Widget, ctx *nanovgo.Context) {
g.WidgetImplement.Draw(self, ctx)
x := float32(g.x)
y := float32(g.y)
w := float32(g.w)
h := float32(g.h)
ctx.BeginPath()
ctx.Rect(x, y, w, h)
ctx.SetFillColor(g.backgroundColor)
ctx.Fill()
if len(g.values) < 2 {
return
}
ctx.BeginPath()
ctx.MoveTo(x, y+h)
dx := float32(len(g.values) - 1)
for i, v := range g.values {
vx := x + float32(i)*w/dx
vy := y + (1.0-v)*h
ctx.LineTo(vx, vy)
}
ctx.LineTo(x+w, y+h)
ctx.SetStrokeColor(nanovgo.MONO(100, 255))
ctx.Stroke()
ctx.SetFillColor(g.foregroundColor)
ctx.Fill()
ctx.SetFontFace(g.theme.FontNormal)
ctx.SetFillColor(g.textColor)
if g.caption != "" {
ctx.SetFontSize(14)
ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignTop)
ctx.Text(x+3, y+1, g.caption)
}
if g.header != "" {
ctx.SetFontSize(18)
ctx.SetTextAlign(nanovgo.AlignRight | nanovgo.AlignTop)
ctx.Text(x+w-3, y+1, g.header)
}
if g.footer != "" {
ctx.SetFontSize(15)
ctx.SetTextAlign(nanovgo.AlignRight | nanovgo.AlignBottom)
ctx.Text(x+w-3, y+h-1, g.footer)
}
ctx.BeginPath()
ctx.Rect(x, y, w, h)
ctx.SetStrokeColor(nanovgo.MONO(100, 255))
ctx.Stroke()
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:57,代码来源:graph.go
注:本文中的github.com/shibukawa/nanovgo.Context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论