当前位置: 首页>>代码示例>>Golang>>正文


Golang Context.SetFillPaint方法代码示例

本文整理汇总了Golang中github.com/shibukawa/nanovgo.Context.SetFillPaint方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.SetFillPaint方法的具体用法?Golang Context.SetFillPaint怎么用?Golang Context.SetFillPaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/shibukawa/nanovgo.Context的用法示例。


在下文中一共展示了Context.SetFillPaint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: drawDropDown

func drawDropDown(ctx *nanovgo.Context, text string, x, y, w, h float32) {

	var cornerRadius float32 = 4.0

	bg := nanovgo.LinearGradient(x, y, x, y+h, nanovgo.RGBA(255, 255, 255, 16), nanovgo.RGBA(0, 0, 0, 16))
	ctx.BeginPath()
	ctx.RoundedRect(x+1, y+1, w-2, h-2, cornerRadius-1)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	ctx.BeginPath()
	ctx.RoundedRect(x+0.5, y+0.5, w-1, h-1, cornerRadius-0.5)
	ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 48))
	ctx.Stroke()

	ctx.SetFontSize(20.0)
	ctx.SetFontFace("sans")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 160))
	ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
	ctx.Text(x+h*0.3, y+h*0.5, text)

	ctx.SetFontSize(h * 1.3)
	ctx.SetFontFace("icons")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 64))
	ctx.SetTextAlign(nanovgo.AlignCenter | nanovgo.AlignMiddle)
	ctx.Text(x+w-h*0.5, y+h*0.5, cpToUTF8(IconCHEVRONRIGHT))
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:27,代码来源:demo.go

示例2: drawSearchBox

func drawSearchBox(ctx *nanovgo.Context, text string, x, y, w, h float32) {
	cornerRadius := h/2 - 1

	// Edit
	bg := nanovgo.BoxGradient(x, y+1.5, w, h, h/2, 5, nanovgo.RGBA(0, 0, 0, 16), nanovgo.RGBA(0, 0, 0, 92))
	ctx.BeginPath()
	ctx.RoundedRect(x, y, w, h, cornerRadius)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	/*      ctx.BeginPath();
	        ctx.RoundedRect(x+0.5f,y+0.5f, w-1,h-1, cornerRadius-0.5f);
	        ctx.StrokeColor(ctx.RGBA(0,0,0,48));
	        ctx.Stroke();*/

	ctx.SetFontSize(h * 1.3)
	ctx.SetFontFace("icons")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 64))
	ctx.SetTextAlign(nanovgo.AlignCenter | nanovgo.AlignMiddle)
	ctx.Text(x+h*0.55, y+h*0.55, cpToUTF8(IconSEARCH))

	ctx.SetFontSize(20.0)
	ctx.SetFontFace("sans")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 32))

	ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
	ctx.Text(x+h*1.05, y+h*0.5, text)

	ctx.SetFontSize(h * 1.3)
	ctx.SetFontFace("icons")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 32))
	ctx.SetTextAlign(nanovgo.AlignCenter | nanovgo.AlignMiddle)
	ctx.Text(x+w-h*0.55, y+h*0.55, cpToUTF8(IconCIRCLEDCROSS))
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:34,代码来源:demo.go

示例3: drawEditBoxBase

func drawEditBoxBase(ctx *nanovgo.Context, x, y, w, h float32) {
	// Edit
	bg := nanovgo.BoxGradient(x+1, y+1+1.5, w-2, h-2, 3, 4, nanovgo.RGBA(255, 255, 255, 32), nanovgo.RGBA(32, 32, 32, 32))
	ctx.BeginPath()
	ctx.RoundedRect(x+1, y+1, w-2, h-2, 4-1)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	ctx.BeginPath()
	ctx.RoundedRect(x+0.5, y+0.5, w-1, h-1, 4-0.5)
	ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 48))
	ctx.Stroke()
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:13,代码来源:demo.go

示例4: drawButton

func drawButton(ctx *nanovgo.Context, preicon int, text string, x, y, w, h float32, col nanovgo.Color) {
	var cornerRadius float32 = 4.0
	var iw float32

	var alpha uint8
	if isBlack(col) {
		alpha = 16
	} else {
		alpha = 32
	}
	bg := nanovgo.LinearGradient(x, y, x, y+h, nanovgo.RGBA(255, 255, 255, alpha), nanovgo.RGBA(0, 0, 0, alpha))
	ctx.BeginPath()
	ctx.RoundedRect(x+1, y+1, w-2, h-2, cornerRadius-1)
	if !isBlack(col) {
		ctx.SetFillColor(col)
		ctx.Fill()
	}
	ctx.SetFillPaint(bg)
	ctx.Fill()

	ctx.BeginPath()
	ctx.RoundedRect(x+0.5, y+0.5, w-1, h-1, cornerRadius-0.5)
	ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 48))
	ctx.Stroke()

	ctx.SetFontSize(20.0)
	ctx.SetFontFace("sans-bold")
	tw, _ := ctx.TextBounds(0, 0, text)
	if preicon != 0 {
		ctx.SetFontSize(h * 1.3)
		ctx.SetFontFace("icons")
		iw, _ = ctx.TextBounds(0, 0, cpToUTF8(preicon))
		iw += h * 0.15

		ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 96))
		ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
		ctx.Text(x+w*0.5-tw*0.5-iw*0.75, y+h*0.5, cpToUTF8(preicon))
	}

	ctx.SetFontSize(20.0)
	ctx.SetFontFace("sans-bold")
	ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
	ctx.SetFillColor(nanovgo.RGBA(0, 0, 0, 160))
	ctx.Text(x+w*0.5-tw*0.5+iw*0.25, y+h*0.5-1, text)
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 160))
	ctx.Text(x+w*0.5-tw*0.5+iw*0.25, y+h*0.5, text)
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:47,代码来源:demo.go

示例5: drawWindow

func drawWindow(ctx *nanovgo.Context, title string, x, y, w, h float32) {
	var cornerRadius float32 = 3.0

	ctx.Save()
	defer ctx.Restore()
	//      ctx.Reset();

	// Window
	ctx.BeginPath()
	ctx.RoundedRect(x, y, w, h, cornerRadius)
	ctx.SetFillColor(nanovgo.RGBA(28, 30, 34, 192))
	//      ctx.FillColor(nanovgo.RGBA(0,0,0,128));
	ctx.Fill()

	// Drop shadow
	shadowPaint := nanovgo.BoxGradient(x, y+2, w, h, cornerRadius*2, 10, nanovgo.RGBA(0, 0, 0, 128), nanovgo.RGBA(0, 0, 0, 0))
	ctx.BeginPath()
	ctx.Rect(x-10, y-10, w+20, h+30)
	ctx.RoundedRect(x, y, w, h, cornerRadius)
	ctx.PathWinding(nanovgo.Hole)
	ctx.SetFillPaint(shadowPaint)
	ctx.Fill()

	// Header
	headerPaint := nanovgo.LinearGradient(x, y, x, y+15, nanovgo.RGBA(255, 255, 255, 8), nanovgo.RGBA(0, 0, 0, 16))
	ctx.BeginPath()
	ctx.RoundedRect(x+1, y+1, w-2, 30, cornerRadius-1)
	ctx.SetFillPaint(headerPaint)
	ctx.Fill()
	ctx.BeginPath()
	ctx.MoveTo(x+0.5, y+0.5+30)
	ctx.LineTo(x+0.5+w-1, y+0.5+30)
	ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 32))
	ctx.Stroke()

	ctx.SetFontSize(18.0)
	ctx.SetFontFace("sans-bold")
	ctx.SetTextAlign(nanovgo.AlignCenter | nanovgo.AlignMiddle)

	ctx.SetFontBlur(2)
	ctx.SetFillColor(nanovgo.RGBA(0, 0, 0, 128))
	ctx.Text(x+w/2, y+16+1, title)

	ctx.SetFontBlur(0)
	ctx.SetFillColor(nanovgo.RGBA(220, 220, 220, 160))
	ctx.Text(x+w/2, y+16, title)
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:47,代码来源:demo.go

示例6: 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

示例7: 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

示例8: 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

示例9: Draw

func (v *VScrollPanel) Draw(self Widget, ctx *nanovgo.Context) {
	if len(v.children) == 0 {
		return
	}
	x := float32(v.x)
	y := float32(v.y)
	w := float32(v.w)
	h := float32(v.h)

	child := v.children[0]
	layout := self.Layout()
	if layout != nil {
		_, v.childPreferredHeight = layout.PreferredSize(self, ctx)
	} else {
		_, v.childPreferredHeight = child.PreferredSize(child, ctx)
	}

	ctx.Save()
	ctx.Translate(x, y)
	ctx.Scissor(0, 0, w, h)
	ctx.Translate(0, -v.scroll*(float32(v.childPreferredHeight)-h))
	if child.Visible() {
		child.Draw(child, ctx)
	}
	ctx.Restore()
	if v.childPreferredHeight > v.h {
		scrollH := h * minF(1.0, h/float32(v.childPreferredHeight))
		scrollH = minF(maxF(20.0, scrollH), h)
		paint := nanovgo.BoxGradient(x+w-12+1, y+4+1, 8, h-8, 3, 4, nanovgo.MONO(0, 32), nanovgo.MONO(0, 92))
		ctx.BeginPath()
		ctx.RoundedRect(x+w-12, y+4, 8, h-8, 3)
		ctx.SetFillPaint(paint)
		ctx.Fill()

		barPaint := nanovgo.BoxGradient(x+y-12-1, y+4+1+(h-8-scrollH)*v.scroll-1, 8, scrollH, 3, 4, nanovgo.MONO(220, 100), nanovgo.MONO(128, 100))
		ctx.BeginPath()
		ctx.RoundedRect(x+w-12+1, y+4+1+(h-8-scrollH)*v.scroll, 8-2, scrollH-2, 2)
		ctx.SetFillPaint(barPaint)
		ctx.Fill()
	}
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:41,代码来源:vscrollpanel.go

示例10: drawCheckBox

func drawCheckBox(ctx *nanovgo.Context, text string, x, y, w, h float32) {

	ctx.SetFontSize(18.0)
	ctx.SetFontFace("sans")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 160))

	ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
	ctx.Text(x+28, y+h*0.5, text)

	bg := nanovgo.BoxGradient(x+1, y+float32(int(h*0.5))-9+1, 18, 18, 3, 3, nanovgo.RGBA(0, 0, 0, 32), nanovgo.RGBA(0, 0, 0, 92))
	ctx.BeginPath()
	ctx.RoundedRect(x+1, y+float32(int(h*0.5))-9, 18, 18, 3)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	ctx.SetFontSize(40)
	ctx.SetFontFace("icons")
	ctx.SetFillColor(nanovgo.RGBA(255, 255, 255, 128))
	ctx.SetTextAlign(nanovgo.AlignCenter | nanovgo.AlignMiddle)
	ctx.Text(x+9+2, y+h*0.5, cpToUTF8(IconCHECK))
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:21,代码来源:demo.go

示例11: drawSpinner

func drawSpinner(ctx *nanovgo.Context, cx, cy, r, t float32) {
	a0 := 0.0 + t*6
	a1 := nanovgo.PI + t*6
	r0 := r
	r1 := r * 0.75

	ctx.Save()
	defer ctx.Restore()

	ctx.BeginPath()
	ctx.Arc(cx, cy, r0, a0, a1, nanovgo.Clockwise)
	ctx.Arc(cx, cy, r1, a1, a0, nanovgo.CounterClockwise)
	ctx.ClosePath()
	ax := cx + cosF(a0)*(r0+r1)*0.5
	ay := cy + sinF(a0)*(r0+r1)*0.5
	bx := cx + cosF(a1)*(r0+r1)*0.5
	by := cy + sinF(a1)*(r0+r1)*0.5
	paint := nanovgo.LinearGradient(ax, ay, bx, by, nanovgo.RGBA(0, 0, 0, 0), nanovgo.RGBA(0, 0, 0, 128))
	ctx.SetFillPaint(paint)
	ctx.Fill()
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:21,代码来源:demo.go

示例12: Draw

func (c *CheckBox) Draw(self Widget, ctx *nanovgo.Context) {
	cx := float32(c.x)
	cy := float32(c.y)
	ch := float32(c.h)
	c.WidgetImplement.Draw(self, ctx)
	fontSize := float32(c.FontSize())
	ctx.SetFontSize(fontSize)
	ctx.SetFontFace(c.theme.FontNormal)
	if c.enabled {
		ctx.SetFillColor(c.theme.TextColor)
	} else {
		ctx.SetFillColor(c.theme.DisabledTextColor)
	}
	ctx.SetTextAlign(nanovgo.AlignLeft | nanovgo.AlignMiddle)
	ctx.Text(cx+1.2*ch+5, cy+ch*0.5, c.caption)
	var bgAlpha uint8
	if c.pushed {
		bgAlpha = 100
	} else {
		bgAlpha = 32
	}
	bgPaint := nanovgo.BoxGradient(cx+1.5, cy+1.5, ch-2.0, ch-2.0, 3, 3, nanovgo.MONO(0, bgAlpha), nanovgo.MONO(0, 180))
	ctx.BeginPath()
	ctx.RoundedRect(cx+1.0, cy+1.0, ch-2.0, ch-2.0, 3)
	ctx.SetFillPaint(bgPaint)
	ctx.Fill()

	if c.checked {
		ctx.SetFontSize(ch)
		ctx.SetFontFace(c.theme.FontIcons)
		if c.enabled {
			ctx.SetFillColor(c.theme.IconColor)
		} else {
			ctx.SetFillColor(c.theme.DisabledTextColor)
		}
		ctx.SetTextAlign(nanovgo.AlignCenter | nanovgo.AlignMiddle)
		ctx.Text(cx+ch*0.5+1.0, cy+ch*0.5, string([]rune{rune(IconCheck)}))
	}
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:39,代码来源:checkbox.go

示例13: Draw

func (p *Popup) Draw(self Widget, ctx *nanovgo.Context) {
	p.RefreshRelativePlacement()

	if !p.visible {
		return
	}
	ds := float32(p.theme.WindowDropShadowSize)
	cr := float32(p.theme.WindowCornerRadius)

	px := float32(p.x)
	py := float32(p.y)
	pw := float32(p.w)
	ph := float32(p.h)
	ah := float32(p.anchorHeight)

	/* Draw a drop shadow */
	shadowPaint := nanovgo.BoxGradient(px, py, pw, ph, cr*2, ds*2, p.theme.DropShadow, p.theme.Transparent)
	ctx.BeginPath()
	ctx.Rect(px-ds, py-ds, pw+ds*2, ph+ds*2)
	ctx.RoundedRect(px, py, pw, ph, cr)
	ctx.PathWinding(nanovgo.Hole)
	ctx.SetFillPaint(shadowPaint)
	ctx.Fill()

	/* Draw window */
	ctx.BeginPath()
	ctx.RoundedRect(px, py, pw, ph, cr)

	ctx.MoveTo(px-15, py+ah)
	ctx.LineTo(px+1, py+ah-15)
	ctx.LineTo(px+1, py+ah+15)

	ctx.SetFillColor(p.theme.WindowPopup)

	ctx.Fill()

	p.WidgetImplement.Draw(self, ctx)
}
开发者ID:shibukawa,项目名称:nanogui-go,代码行数:38,代码来源:popup.go

示例14: drawSlider

func drawSlider(ctx *nanovgo.Context, pos, x, y, w, h float32) {
	cy := y + float32(int(h*0.5))
	kr := float32(int(h * 0.25))

	ctx.Save()
	defer ctx.Restore()
	//      ctx.ClearState(vg);

	// Slot
	bg := nanovgo.BoxGradient(x, cy-2+1, w, 4, 2, 2, nanovgo.RGBA(0, 0, 0, 32), nanovgo.RGBA(0, 0, 0, 128))
	ctx.BeginPath()
	ctx.RoundedRect(x, cy-2, w, 4, 2)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	// Knob Shadow
	bg = nanovgo.RadialGradient(x+float32(int(pos*w)), cy+1, kr-3, kr+3, nanovgo.RGBA(0, 0, 0, 64), nanovgo.RGBA(0, 0, 0, 0))
	ctx.BeginPath()
	ctx.Rect(x+float32(int(pos*w))-kr-5, cy-kr-5, kr*2+5+5, kr*2+5+5+3)
	ctx.Circle(x+float32(int(pos*w)), cy, kr)
	ctx.PathWinding(nanovgo.Hole)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	// Knob
	knob := nanovgo.LinearGradient(x, cy-kr, x, cy+kr, nanovgo.RGBA(255, 255, 255, 16), nanovgo.RGBA(0, 0, 0, 16))
	ctx.BeginPath()
	ctx.Circle(x+float32(int(pos*w)), cy, kr-1)
	ctx.SetFillColor(nanovgo.RGBA(40, 43, 48, 255))
	ctx.Fill()
	ctx.SetFillPaint(knob)
	ctx.Fill()

	ctx.BeginPath()
	ctx.Circle(x+float32(int(pos*w)), cy, kr-0.5)
	ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 92))
	ctx.Stroke()
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:38,代码来源:demo.go

示例15: drawGraph

func drawGraph(ctx *nanovgo.Context, x, y, w, h, t float32) {
	var sx, sy [6]float32
	dx := w / 5.0

	samples := []float32{
		(1 + sinF(t*1.2345+cosF(t*0.33457)*0.44)) * 0.5,
		(1 + sinF(t*0.68363+cosF(t*1.3)*1.55)) * 0.5,
		(1 + sinF(t*1.1642+cosF(t*0.33457)*1.24)) * 0.5,
		(1 + sinF(t*0.56345+cosF(t*1.63)*0.14)) * 0.5,
		(1 + sinF(t*1.6245+cosF(t*0.254)*0.3)) * 0.5,
		(1 + sinF(t*0.345+cosF(t*0.03)*0.6)) * 0.5,
	}

	for i := 0; i < 6; i++ {
		sx[i] = x + float32(i)*dx
		sy[i] = y + h*samples[i]*0.8
	}

	// Graph background
	bg := nanovgo.LinearGradient(x, y, x, y+h, nanovgo.RGBA(0, 160, 192, 0), nanovgo.RGBA(0, 160, 192, 64))
	ctx.BeginPath()
	ctx.MoveTo(sx[0], sy[0])
	for i := 1; i < 6; i++ {
		ctx.BezierTo(sx[i-1]+dx*0.5, sy[i-1], sx[i]-dx*0.5, sy[i], sx[i], sy[i])
	}
	ctx.LineTo(x+w, y+h)
	ctx.LineTo(x, y+h)
	ctx.SetFillPaint(bg)
	ctx.Fill()

	// Graph line
	ctx.BeginPath()
	ctx.MoveTo(sx[0], sy[0]+2)
	for i := 1; i < 6; i++ {
		ctx.BezierTo(sx[i-1]+dx*0.5, sy[i-1]+2, sx[i]-dx*0.5, sy[i]+2, sx[i], sy[i]+2)
	}
	ctx.SetStrokeColor(nanovgo.RGBA(0, 0, 0, 32))
	ctx.SetStrokeWidth(3.0)
	ctx.Stroke()

	ctx.BeginPath()
	ctx.MoveTo(sx[0], sy[0])
	for i := 1; i < 6; i++ {
		ctx.BezierTo(sx[i-1]+dx*0.5, sy[i-1], sx[i]-dx*0.5, sy[i], sx[i], sy[i])
	}
	ctx.SetStrokeColor(nanovgo.RGBA(0, 160, 192, 255))
	ctx.SetStrokeWidth(3.0)
	ctx.Stroke()

	// Graph sample pos
	for i := 0; i < 6; i++ {
		bg = nanovgo.RadialGradient(sx[i], sy[i]+2, 3.0, 8.0, nanovgo.RGBA(0, 0, 0, 32), nanovgo.RGBA(0, 0, 0, 0))
		ctx.BeginPath()
		ctx.Rect(sx[i]-10, sy[i]-10+2, 20, 20)
		ctx.SetFillPaint(bg)
		ctx.Fill()
	}

	ctx.BeginPath()
	for i := 0; i < 6; i++ {
		ctx.Circle(sx[i], sy[i], 4.0)
	}
	ctx.SetFillColor(nanovgo.RGBA(0, 160, 192, 255))
	ctx.Fill()
	ctx.BeginPath()
	for i := 0; i < 6; i++ {
		ctx.Circle(sx[i], sy[i], 2.0)
	}
	ctx.SetFillColor(nanovgo.RGBA(220, 220, 220, 255))
	ctx.Fill()

	ctx.SetStrokeWidth(1.0)
}
开发者ID:hajimehoshi,项目名称:nanovgo,代码行数:73,代码来源:demo.go


注:本文中的github.com/shibukawa/nanovgo.Context.SetFillPaint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。