1: what is cario?see details in
2: build cario dev environment
(1)download pixman-0.22.2 and cairo-1.10.2
(2)install cario and pixman dependency
- sudo apt-get install libpng12-dev libz-dev libxrender-dev libfontconfig1-dev
(3)install pixman
- cd pixman-0.22.2/
- ./configure
- make
- sudo make install
(4)install cario
- cd cairo-1.10.2/
-
./configure
-
make
-
sudo make install
3: CLI dev
- gcc -o hello -I/usr/local/include/cairo -I/usr/local/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -L/usr/local/lib -lcairo hello.c
or use shortcut command
- gcc -o hello $(pkg-config --cflags --libs cairo) hello.c
4: GUI dev
(1) build eclipse + cdt (google for details)
(2) new c project, set project properties as, then run project
5: hello.c code
- #include <cairo.h>
-
-
int main (int argc, char *argv[])
-
{
-
cairo_surface_t *surface =
-
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
-
cairo_t *cr =
-
cairo_create (surface);
-
-
cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
-
cairo_set_font_size (cr, 32.0);
-
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
-
cairo_move_to (cr, 10.0, 50.0);
-
cairo_show_text (cr, "Hello, world");
-
-
cairo_destroy (cr);
-
cairo_surface_write_to_png (surface, "hello.png");
-
cairo_surface_destroy (surface);
-
return 0;
-
}
阅读(3389) | 评论(0) | 转发(0) |