# Testbed for exploring OpenVG on the Raspberry Pi.
<a href="http://www.flickr.com/photos/ajstarks/7811750326/" title="rotext by ajstarks, on Flickr"><img src="http://farm8.staticflickr.com/7249/7811750326_614ea891ae.jpg" width="500" height="281" alt="rotext"></a>
## First program
Here is the graphics equivalent of "hello, world"
// first OpenVG program
// Anthony Starks (ajstarks@gmail.com)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "fontinfo.h"
#include "shapes.h"
int main() {
int width, height;
char s[3];
init(&width, &height); // Graphics initialization
Start(width, height); // Start the picture
Background(0, 0, 0); // Black background
Fill(44, 77, 232, 1); // Big blue marble
Circle(width / 2, 0, width); // The "world"
Fill(255, 255, 255, 1); // White text
TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10); // Greetings
End(); // End the picture
fgets(s, 2, stdin); // look at the pic, end with [RETURN]
finish(); // Graphics cleanup
exit(0);
}
<a href="http://www.flickr.com/photos/ajstarks/7828969180/" title="hellovg by ajstarks, on Flickr"><img src="http://farm9.staticflickr.com/8436/7828969180_b73db3bf19.jpg" width="500" height="281" alt="hellovg"></a>
## API
<a href="http://www.flickr.com/photos/ajstarks/7717370238/" title="OpenVG refcard by ajstarks, on Flickr"><img src="http://farm8.staticflickr.com/7256/7717370238_1d632cb179.jpg" width="500" height="281" alt="OpenVG refcard"></a>
Coordinates are VGfloat values, with the origin at the lower left, with x increasing to the right, and y increasing up.
OpenVG specifies colors as a VGfloat array containing red, green, blue, alpha values ranging from 0.0 to 1.0, but typically colors are specified as RGBA (0-255 for RGB, A from 0.0 to 1.0)
### Window (canvas) functions
void WindowClear()
WindowClear clears the window to previously set background colour
void AreaClear(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
AreaClear clears a given rectangle in window coordinates
void WindowOpacity(unsigned int a)
WindowOpacity sets the window opacity
void WindowPosition(int x, int y)
WindowPosition moves the window to given position
### Setup and shutdown
void init(int *w, int *h)
Initialize the graphics: width and height of the canvas are returned. This should begin every program.
void initWindowSize(int x, int y, unsigned int w, unsigned int h)
Initialize with specific dimensions
void finish()
Shutdown the graphics. This should end every program.
void Start(int width, int height)
Begin the picture, clear the screen with a default white, set the stroke and fill to black.
void End()
End the picture, rendering to the screen.
void SaveEnd(char *filename)
End the picture, rendering to the screen, save the raster to the named file as 4-byte RGBA words, with a stride of
width*4 bytes. The program raw2png converts the "raw" raster to png.
void saveterm(), restoreterm(), rawterm()
Terminal settings, save current settings, restore settings, put the terminal in raw mode.
### Attributes
void setfill(float color[4])
Set the fill color
void Background(unsigned int r, unsigned int g, unsigned int b)
Fill the screen with the background color defined from RGB values.
void BackgroundRGB(unsigned int r, unsigned int g, unsigned int b, VGfloat a)
clears the screen to a background color with alpha
void StrokeWidth(float width)
Set the stroke width.
void RGBA(unsigned int r, unsigned int g, unsigned int b, VGfloat a, VGfloat color[4])
fill a color vector from RGBA values.
void RGB(unsigned int r, unsigned int g, unsigned int b, VGfloat color[4])
fill a color vector from RGB values.
void Stroke(unsigned int r, unsigned int g, unsigned int b, VGfloat a)
Set the Stroke color using RGBA values.
void Fill(unsigned int r, unsigned int g, unsigned int b, VGfloat a)
Set the Fill color using RGBA values.
void FillLinearGradient(VGfloat x1, VGfloat y1, VGfloat x2, VGfloat y2, VGfloat *stops, int n)
Set the fill to a linear gradient bounded by (x1, y1) and (x2, y2). using offsets and colors specified in n number of stops
void FillRadialGradient(VGfloat cx, VGfloat cy, VGfloat fx VGfloat fy, VGfloat r, VGfloat *stops, int n)
Set the fill to a radial gradient centered at (cx, cy) with radius r, and focal point at (fx, ry), using offsets and colors specified in n number of stops
### Shapes
void Line(VGfloat x1, VGfloat y1, VGfloat x2, VGfloat y2)
Draw a line between (x1, y1) and (x2, y2).
void Rect(VGfloat x, VGfloat y, VGfloat w, VGfloat h)
Draw a rectangle with its origin (lower left) at (x,y), and size is (width,height).
void RectOutline(VGfloat x, VGfloat y, VGfloat w, VGfloat h)
Outlined version
void Roundrect(VGfloat x, VGfloat y, VGfloat w, VGfloat h, VGfloat rw, VGfloat rh)
Draw a rounded rectangle with its origin (lower left) at (x,y), and size is (width,height).
The width and height of the corners are specified with (rw,rh).
void RoundrectOutline(VGfloat x, VGfloat y, VGfloat w, VGfloat h, VGfloat rw, VGfloat rh)
Outlined version
void Polygon(VGfloat *x, VGfloat *y, VGint n)
Draw a polygon using the coordinates in arrays pointed to by x and y. The number of coordinates is n.
void Polyline(VGfloat *x, VGfloat *y, VGint n)
Draw a polyline using the coordinates in arrays pointed to by x and y. The number of coordinates is n.
void Circle(VGfloat x, VGfloat y, VGfloat d)
Draw a circle centered at (x,y) with diameter d.
void CircleOutline(VGfloat x, VGfloat y, VGfloat r)
Outlined version
void Ellipse(VGfloat x, VGfloat y, VGfloat w, VGfloat h)
Draw an ellipse centered at (x,y) with radii (w, h).
void EllipseOutline(VGfloat x, VGfloat y, VGfloat w, VGfloat h)
Outlined version
void Qbezier(VGfloat sx, VGfloat sy, VGfloat cx, VGfloat cy, VGfloat ex, VGfloat ey)
Draw a quadratic bezier curve beginning at (sx, sy), using control points at (cx, cy), ending at (ex, ey).
void QbezierOutline(VGfloat sx, VGfloat sy, VGfloat cx, VGfloat cy, VGfloat ex, VGfloat ey)
Outlined version
void Cbezier(VGfloat sx, VGfloat sy, VGfloat cx, VGfloat cy, VGfloat px, VGfloat py, VGfloat ex, VGfloat ey)
Draw a cubic bezier curve beginning at (sx, sy), using control points at (cx, cy) and (px, py), ending at (ex, ey).
void CbezierOutline(VGfloat sx, VGfloat sy, VGfloat cx, VGfloat cy, VGfloat px, VGfloat py, VGfloat ex, VGfloat ey)
Outlined version
void Arc(VGfloat x, VGfloat y, VGfloat w, VGfloat h, VGfloat sa, VGfloat aext)
Draw an elliptical arc centered at (x, y), with width and height at (w, h). Start angle (degrees) is sa, angle extent is aext.
void ArcOutline(VGfloat x, VGfloat y, VGfloat w, VGfloat h, VGfloat sa, VGfloat aext)
Outlined version
### Text and Images
void Text(VGfloat x, VGfloat y, char* s, Fontinfo f, int pointsize)
Draw a the text srtring (s) at location (x,y), using pointsize.
void TextMid(VGfloat x, VGfloat y, char* s, Fontinfo f, int pointsize)
Draw a the text srtring (s) at centered at location (x,y), using pointsize.
void TextEnd(VGfloat x, VGfloat y, char* s, Fontinfo f, int pointsize)
Draw a the text srtring (s) at with its lend aligned to location (x,y), using pointsize
VGfloat TextWidth(char *s, Fontinfo f, int pointsize)
Return the width of text
VGfloat TextHeight(Fontinfo f, int pointsize)
Return a font's height
TextDepth(Fontinfo f, int pointsize)
Return a font's distance beyond the baseline.
void Image(VGfloat x, VGfloat y, int w, int h, char * filename)
place a JPEG image with dimensions (w,h) at (x,y).
### Transformations
void Translate(VGfloat x, VGfloat y)
Translate the coordinate system to (x,y).
void Rotate(VGfloat r)
Rotate the coordinate system around angle r (degrees).
void Scale(VGfloat x, VGfloat y)
Scale by x,y.
void Shear(VGfloat x, VGfloat y)
Shear by the angles x,y.
## Clipping
void C
没有合适的资源?快使用搜索试试~ 我知道了~
openvg:探索OpenVG的工具
共92个文件
png:22个
jpg:20个
go:19个
5星 · 超过95%的资源 需积分: 44 8 下载量 200 浏览量
2021-02-05
01:58:17
上传
评论
收藏 3.83MB ZIP 举报
温馨提示
在Raspberry Pi上探索OpenVG的测试平台。 第一个程序 这是等效于“你好,世界”的图形 // first OpenVG program // Anthony Starks (ajstarks@gmail.com) #include <stdio> #include <stdlib> #include <unistd> #include "VG/openvg.h" #include "VG/vgu.h" #include "fontinfo.h" #include "shapes.h" int main() { int width, height; char s[3
资源详情
资源评论
资源推荐
收起资源包目录
openvg-master.zip (92个子文件)
openvg-master
DejaVuSansMono.inc 222KB
.gitignore 24B
README.md 14KB
openvg.go 18KB
doc.go 3KB
libshapes.c 22KB
LICENSE 1KB
screenshots
hellovg.png 37KB
chars.png 54KB
vgplot.png 147KB
sunearth.png 26KB
raspi.png 17KB
image.png 1.47MB
gradient.png 66KB
slide2.raw.png 29KB
refcard.png 65KB
planets.png 22KB
rand.png 338KB
slide5.raw.png 21KB
slide1.raw.png 39KB
slide0.raw.png 17KB
fontrange.png 22KB
rotext.png 388KB
slide4.raw.png 50KB
tb.png 94KB
advert.png 33KB
testpattern.png 35KB
slide3.raw.png 63KB
go-client
shapedemo
shapedemo.go 22KB
desert3.jpg 38KB
starx.jpg 6KB
desert6.jpg 37KB
desert2.jpg 43KB
desert8.jpg 53KB
desert1.jpg 46KB
desert0.jpg 42KB
desert7.jpg 48KB
desert5.jpg 44KB
desert4.jpg 37KB
planets
planets.go 2KB
chars
chars.go 2KB
picshow
picshow.go 2KB
randcircle
randcircle.go 1KB
raspi
raspi.go 2KB
bubtrail
bubtrail.go 1KB
splash
splash.go 3KB
vgplot
AAPL 3KB
CSCO 2KB
RIMM 2KB
T 2KB
vgplot.go 9KB
plotdemo 210B
GOOG 3KB
AMZN 3KB
DELL 2KB
VZ 2KB
MSFT 2KB
particles
particles.go 3KB
twh
poweredby_nytimes_30a.png 697B
twh.go 14KB
clip
clip.go 991B
hgrad
hgrad.go 1KB
clock
clock.go 7KB
colortab
colortab.go 2KB
svgcolors.txt 4KB
hellovg
hellovg.go 966B
fontutil
font2openvg.cpp 11KB
client
desert3.jpg 38KB
starx.jpg 6KB
mouse-hellovg.c 5KB
screensize.c 383B
hellovg.c 1KB
desert6.jpg 37KB
desert2.jpg 43KB
particles.c 3KB
clip.c 940B
desert8.jpg 53KB
shapedemo.c 17KB
desert1.jpg 46KB
desert0.jpg 42KB
desert7.jpg 48KB
desert5.jpg 44KB
Makefile 2KB
desert4.jpg 37KB
oglinit.c 6KB
fontinfo.h 391B
DejaVuSerif.inc 267KB
shapes.h 9KB
Makefile 2KB
DejaVuSans.inc 219KB
eglstate.h 492B
util
raw2png.go 601B
共 92 条
- 1
Jeckaijew
- 粉丝: 25
- 资源: 4533
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5