Mercurial > MadButterfly
comparison src/X_main.c @ 6:772511b8b9be
Cairo specify RGB values in range 0.0 ~ 1.0.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 26 Jul 2008 02:41:00 +0800 |
parents | 9c331ec9e210 |
children | 569f3168ba53 |
comparison
equal
deleted
inserted
replaced
5:9c331ec9e210 | 6:772511b8b9be |
---|---|
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 <X11/Xutil.h> | |
4 #include <cairo.h> | 5 #include <cairo.h> |
5 | 6 |
6 #include <string.h> | 7 #include <string.h> |
7 #include "shapes.h" | 8 #include "shapes.h" |
8 | 9 |
13 path = sh_path_new("M80 80 c 20 5 -30 20 10 30 l -30 0 z"); | 14 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 memset(coord.aggr_matrix, 0, sizeof(co_aix) * 6); |
15 coord.aggr_matrix[0] = 1; | 16 coord.aggr_matrix[0] = 1; |
16 coord.aggr_matrix[1] = 0.5; | 17 coord.aggr_matrix[1] = 0.5; |
17 coord.aggr_matrix[4] = 1; | 18 coord.aggr_matrix[4] = 1; |
18 coord.aggr_matrix[5] = 0.5; | 19 coord.aggr_matrix[5] = 0; |
19 sh_path_transform(path, &coord); | 20 sh_path_transform(path, &coord); |
20 sh_path_draw(path, cr); | 21 sh_path_draw(path, cr); |
21 } | 22 } |
22 | 23 |
23 void drawing(cairo_surface_t *surface, int w, int h) { | 24 void drawing(cairo_surface_t *surface, int w, int h) { |
24 cairo_t *cr; | 25 cairo_t *cr; |
25 | 26 |
26 cr = cairo_create(surface); | 27 cr = cairo_create(surface); |
27 cairo_set_source_rgb(cr, 0xff, 0xff, 0x80); | 28 cairo_set_source_rgb(cr, 0.9, 0.1, 0.1); |
28 draw_path(cr, w, h); | 29 draw_path(cr, w, h); |
30 cairo_set_source_rgb(cr, 0.5, 0.9, 0.8); | |
29 cairo_move_to(cr, 10, h / 2); | 31 cairo_move_to(cr, 10, h / 2); |
30 cairo_set_font_size(cr, 48.0); | 32 cairo_set_font_size(cr, 48.0); |
31 cairo_text_path(cr, "hello \xe4\xb8\xad\xe6\x96\x87"); | 33 cairo_text_path(cr, "hello \xe4\xb8\xad\xe6\x96\x87"); |
32 cairo_set_line_width(cr, 1); | 34 cairo_set_line_width(cr, 2); |
33 cairo_stroke(cr); | 35 cairo_stroke(cr); |
34 } | 36 } |
35 | 37 |
36 int | 38 int |
37 main(int argc, char * const argv[]) { | 39 main(int argc, char * const argv[]) { |