Mercurial > MadButterfly
comparison src/X_main.c @ 5:9c331ec9e210
SVG path is partially supported
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 26 Jul 2008 01:37:35 +0800 |
parents | 164162781a7a |
children | 772511b8b9be |
comparison
equal
deleted
inserted
replaced
4:399517bf65dc | 5:9c331ec9e210 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <unistd.h> | 2 #include <unistd.h> |
3 #include <X11/Xlib.h> | 3 #include <X11/Xlib.h> |
4 #include <cairo.h> | 4 #include <cairo.h> |
5 | |
6 #include <string.h> | |
7 #include "shapes.h" | |
8 | |
9 void draw_path(cairo_t *cr, int w, int h) { | |
10 shape_t *path; | |
11 coord_t coord; | |
12 | |
13 path = sh_path_new("M80 80 c 20 5 -30 20 10 30 l -30 0 z"); | |
14 memset(coord.aggr_matrix, 0, sizeof(co_aix) * 6); | |
15 coord.aggr_matrix[0] = 1; | |
16 coord.aggr_matrix[1] = 0.5; | |
17 coord.aggr_matrix[4] = 1; | |
18 coord.aggr_matrix[5] = 0.5; | |
19 sh_path_transform(path, &coord); | |
20 sh_path_draw(path, cr); | |
21 } | |
5 | 22 |
6 void drawing(cairo_surface_t *surface, int w, int h) { | 23 void drawing(cairo_surface_t *surface, int w, int h) { |
7 cairo_t *cr; | 24 cairo_t *cr; |
8 | 25 |
9 cr = cairo_create(surface); | 26 cr = cairo_create(surface); |
10 cairo_set_source_rgb(cr, 0xff, 0xff, 0x80); | 27 cairo_set_source_rgb(cr, 0xff, 0xff, 0x80); |
28 draw_path(cr, w, h); | |
11 cairo_move_to(cr, 10, h / 2); | 29 cairo_move_to(cr, 10, h / 2); |
12 cairo_set_font_size(cr, 48.0); | 30 cairo_set_font_size(cr, 48.0); |
13 cairo_text_path(cr, "hello \xe4\xb8\xad\xe6\x96\x87"); | 31 cairo_text_path(cr, "hello \xe4\xb8\xad\xe6\x96\x87"); |
14 cairo_set_line_width(cr, 1); | 32 cairo_set_line_width(cr, 1); |
15 cairo_stroke(cr); | 33 cairo_stroke(cr); |