コード例 #1
0
ファイル: clock.go プロジェクト: jhautefeuille/openvg
func combohand(cx, cy, px, py, r, stroke openvg.VGfloat, t float64, value int, color string) {
	thinr := float64(r * 0.25)
	t = minadjust(t, value) * deg2rad
	tx := cx + openvg.VGfloat(thinr*math.Cos(t))
	ty := cy + openvg.VGfloat(thinr*math.Sin(t))
	openvg.FillColor(color)
	openvg.Ellipse(px, py, stroke*2, stroke*2)
	openvg.Ellipse(tx, ty, stroke*2, stroke*2)
	openvg.StrokeWidth(stroke)
	openvg.StrokeColor(color)
	openvg.Line(cx, cy, tx, ty)
	openvg.StrokeWidth(stroke * 2)
	openvg.Line(tx, ty, px, py)
	openvg.StrokeWidth(0)
}
コード例 #2
0
ファイル: shapedemo.go プロジェクト: sequoiar/openvg
// rshapes draws shapes with random colors, openvg.Strokes, and sizes.
func rshapes(width, height, n int) {

	var sx, sy, cx, cy, px, py, ex, ey, pox, poy float64

	np := 10
	polyx := make([]float64, np)
	polyy := make([]float64, np)
	openvg.Start(width, height)
	for i := 0; i < n; i++ {
		openvg.FillRGB(randcolor(), randcolor(), randcolor(), rand.Float64())
		openvg.Ellipse(randf(width), randf(height), randf(200), randf(100))
		openvg.Circle(randf(width), randf(height), randf(100))
		openvg.Rect(randf(width), randf(height), randf(200), randf(100))
		openvg.Arc(randf(width), randf(height), randf(200), randf(200), randf(360), randf(360))

		sx = randf(width)
		sy = randf(height)
		openvg.StrokeRGB(randcolor(), randcolor(), randcolor(), 1)
		openvg.StrokeWidth(randf(5))
		openvg.Line(sx, sy, sx+randf(200), sy+randf(100))
		openvg.StrokeWidth(0)

		sx = randf(width)
		sy = randf(height)
		ex = sx + randf(200)
		ey = sy
		cx = sx + ((ex - sx) / 2.0)
		cy = sy + randf(100)
		openvg.Qbezier(sx, sy, cx, cy, ex, ey)

		sx = randf(width)
		sy = randf(height)
		ex = sx + randf(200)
		ey = sy
		cx = sx + ((ex - sx) / 2.0)
		cy = sy + randf(100)
		px = cx
		py = sy - randf(100)
		openvg.Cbezier(sx, sy, cx, cy, px, py, ex, ey)

		pox = randf(width)
		poy = randf(height)
		for j := 0; j < np; j++ {
			polyx[j] = pox + randf(200)
			polyy[j] = poy + randf(100)
		}
		openvg.Polygon(polyx, polyy) // , np)

		pox = randf(width)
		poy = randf(height)
		for j := 0; j < np; j++ {
			polyx[j] = pox + randf(200)
			polyy[j] = poy + randf(100)
		}
		openvg.Polyline(polyx, polyy) // , np)
	}
	openvg.FillRGB(128, 0, 0, 1)
	openvg.Text(20, 20, "OpenVG on the Raspberry Pi", "sans", 32)
	openvg.End()
}
コード例 #3
0
ファイル: twh.go プロジェクト: Ebiroll/openvg
// drop shows the raindrop icon
func (d *dimen) drop(color string) {
	x, y, w, h := d.x, d.y, d.width, d.height
	openvg.FillColor(color)
	openvg.Ellipse(x+(w/2), y+(h*0.40), w*0.52, h*0.65)
	xp := []openvg.VGfloat{x + (w / 2), x + (w * 0.25), x + (w * 0.75)}
	yp := []openvg.VGfloat{y + h, y + (h / 2), y + (h / 2)}
	openvg.Polygon(xp, yp)
}
コード例 #4
0
ファイル: clock.go プロジェクト: jhautefeuille/openvg
func roundhand(cx, cy, px, py, stroke openvg.VGfloat, color string) {
	openvg.StrokeWidth(stroke)
	openvg.StrokeColor(color)
	openvg.Line(cx, cy, px, py)
	openvg.StrokeWidth(0)
	openvg.FillColor(color)
	openvg.Ellipse(px, py, stroke, stroke)
}
コード例 #5
0
ファイル: clock.go プロジェクト: jhautefeuille/openvg
func secondhand(cx, cy, sx, sy, textsize openvg.VGfloat) {
	openvg.FillColor(secolor, 0.4)
	openvg.Ellipse(sx, sy, textsize, textsize)
	if secline {
		openvg.StrokeWidth(textsize / 6)
		openvg.StrokeColor(secolor)
		openvg.Line(cx, cy, sx, sy)
		openvg.StrokeWidth(0)
	}
}
コード例 #6
0
ファイル: clock.go プロジェクト: jhautefeuille/openvg
func face(x, y, r openvg.VGfloat, ts int) {
	var fx, fy, va openvg.VGfloat
	va = openvg.VGfloat(ts) / 2.0
	secsize := openvg.VGfloat(ts) / 3
	radius := float64(r)
	ir := radius * 1.2
	// hour display
	openvg.FillColor(digitcolor)
	openvg.StrokeColor(digitcolor)
	openvg.StrokeWidth(5)
	for h := 12; h > 0; h-- {
		t := hourangles[h%12] * deg2rad
		fx = x + openvg.VGfloat(radius*math.Cos(t))
		fy = y + openvg.VGfloat(radius*math.Sin(t))
		ix := x + openvg.VGfloat(ir*math.Cos(t))
		iy := y + openvg.VGfloat(ir*math.Sin(t))
		if showdigits {
			openvg.TextMid(fx, fy-va, hourdigits[h%12], "sans", ts)
		} else {
			openvg.Line(fx, fy, ix, iy)
		}
	}
	// second display
	openvg.FillColor(dotcolor)
	openvg.StrokeColor(dotcolor)
	openvg.StrokeWidth(2)
	re := radius * edge
	for a := 0.0; a < 360; a += 6.0 {
		t := a * deg2rad
		sx := x + openvg.VGfloat(re*math.Cos(t))
		sy := y + openvg.VGfloat(re*math.Sin(t))
		if showdots {
			openvg.Ellipse(sx, sy, secsize, secsize)
		} else {
			ix := x + openvg.VGfloat(ir*math.Cos(t))
			iy := y + openvg.VGfloat(ir*math.Sin(t))
			openvg.Line(sx, sy, ix, iy)
		}
	}
	openvg.StrokeWidth(0)

}
コード例 #7
0
ファイル: shapedemo.go プロジェクト: sequoiar/openvg
// refcard shows a reference card of shapes
func refcard(width, height int) {
	shapenames := []string{
		"Circle",
		"Ellipse",
		"Rectangle",
		"Rounded Rectangle",
		"Line",
		"Polyline",
		"Polygon",
		"Arc",
		"Quadratic Bezier",
		"Cubic Bezier",
		"Image",
	}
	top := float64(height) * .95
	sx := float64(width) * 0.10
	sy := top
	sw := float64(width) * .05
	sh := float64(height) * .045
	dotsize := 7.0
	spacing := 2.0
	fontsize := int(float64(height) * .033)
	shapecolor := Color{202, 225, 255, 1.0}

	openvg.Start(width, height)
	openvg.FillRGB(128, 0, 0, 1)
	openvg.TextEnd(float64(width-20), float64(height/2),
		"OpenVG on the Raspberry Pi", "sans", fontsize+(fontsize/2))
	openvg.FillRGB(0, 0, 0, 1)
	for _, s := range shapenames {
		openvg.Text(sx+sw+sw/2, sy, s, "sans", fontsize)
		sy -= sh * spacing
	}
	sy = top
	cx := sx + (sw / 2)
	ex := sx + sw
	openvg.FillRGB(shapecolor.red, shapecolor.green, shapecolor.blue, shapecolor.alpha)
	openvg.Circle(cx, sy, sw)
	coordpoint(cx, sy, dotsize, shapecolor)
	sy -= sh * spacing
	openvg.Ellipse(cx, sy, sw, sh)
	coordpoint(cx, sy, dotsize, shapecolor)
	sy -= sh * spacing
	openvg.Rect(sx, sy, sw, sh)
	coordpoint(sx, sy, dotsize, shapecolor)
	sy -= sh * spacing
	openvg.Roundrect(sx, sy, sw, sh, 20, 20)
	coordpoint(sx, sy, dotsize, shapecolor)
	sy -= sh * spacing

	openvg.StrokeWidth(1)
	openvg.StrokeRGB(204, 204, 204, 1)
	openvg.Line(sx, sy, ex, sy)
	coordpoint(sx, sy, dotsize, shapecolor)
	coordpoint(ex, sy, dotsize, shapecolor)
	sy -= sh

	px := []float64{sx, sx + (sw / 4), sx + (sw / 2), sx + ((sw * 3) / 4), sx + sw}
	py := []float64{sy, sy - sh, sy, sy - sh, sy}

	openvg.Polyline(px, py) // , 5)
	coordpoint(px[0], py[0], dotsize, shapecolor)
	coordpoint(px[1], py[1], dotsize, shapecolor)
	coordpoint(px[2], py[2], dotsize, shapecolor)
	coordpoint(px[3], py[3], dotsize, shapecolor)
	coordpoint(px[4], py[4], dotsize, shapecolor)
	sy -= sh * spacing

	py[0] = sy
	py[1] = sy - sh
	py[2] = sy - (sh / 2)
	py[3] = py[1] - (sh / 4)
	py[4] = sy
	openvg.Polygon(px, py) // , 5)
	sy -= (sh * spacing) + sh

	openvg.Arc(sx+(sw/2), sy, sw, sh, 0, 180)
	coordpoint(sx+(sw/2), sy, dotsize, shapecolor)
	sy -= sh * spacing

	var cy, ey float64
	cy = sy + (sh / 2)
	ey = sy
	openvg.Qbezier(sx, sy, cx, cy, ex, ey)
	coordpoint(sx, sy, dotsize, shapecolor)
	coordpoint(cx, cy, dotsize, shapecolor)
	coordpoint(ex, ey, dotsize, shapecolor)
	sy -= sh * spacing

	ey = sy
	cy = sy + sh
	openvg.Cbezier(sx, sy, cx, cy, cx, sy, ex, ey)
	coordpoint(sx, sy, dotsize, shapecolor)
	coordpoint(cx, cy, dotsize, shapecolor)
	coordpoint(cx, sy, dotsize, shapecolor)
	coordpoint(ex, ey, dotsize, shapecolor)

	sy -= (sh * spacing * 1.5)
	openvg.Image(sx, sy, 110, 110, "starx.jpg")

	openvg.End()
}
コード例 #8
0
ファイル: clock.go プロジェクト: jhautefeuille/openvg
func frame(cx, cy, framesize, facesize, textsize openvg.VGfloat, framecolor, facecolor string) {
	openvg.FillColor(framecolor)
	openvg.Roundrect(cx-framesize/2, cy-framesize/2, framesize, framesize, textsize, textsize)
	openvg.FillColor(facecolor)
	openvg.Ellipse(cx, cy, facesize*2.4, facesize*2.4)
}
コード例 #9
0
ファイル: clock.go プロジェクト: jhautefeuille/openvg
func centerdot(cx, cy, size openvg.VGfloat) {
	openvg.FillColor(centercolor)
	openvg.Ellipse(cx, cy, size, size)
}