Ejemplo n.º 1
0
// 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()
}
Ejemplo n.º 2
0
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)
}