annotate src/shape_rect.c @ 1381:9a585df24e52

Consider the width and height attribute for the rect elements. The inkscape will change the width and height directly without using transform when we resize the rectangle.
author wycc
date Wed, 23 Mar 2011 23:02:36 +0800
parents bae104d8d247
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 448
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 448
diff changeset
2 // vim: sw=4:ts=8:sts=4
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #include <stdio.h>
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
4 #include <stdlib.h>
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
5 #include <string.h>
186
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
6 #include "mb_types.h"
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
7 #include "mb_shapes.h"
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 typedef struct _sh_rect {
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 shape_t shape;
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 co_aix x, y;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
12 co_aix w, h;
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13 co_aix rx, ry;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
14 co_aix poses[12][2];
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
15
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
16 redraw_man_t *rdman; /*!< \brief This is used by sh_rect_free() */
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 } sh_rect_t;
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
19 int _sh_rect_size = sizeof(sh_rect_t);
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
20
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 40
diff changeset
21 static void sh_rect_free(shape_t *shape) {
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
22 sh_rect_t *rect = (sh_rect_t *)shape;
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
23
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
24 elmpool_elm_free(rect->rdman->sh_rect_pool, rect);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 40
diff changeset
25 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 40
diff changeset
26
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
27 shape_t *rdman_shape_rect_new(redraw_man_t *rdman,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
28 co_aix x, co_aix y, co_aix w, co_aix h,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
29 co_aix rx, co_aix ry) {
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
30 sh_rect_t *rect;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
31
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
32 rect = (sh_rect_t *)elmpool_elm_alloc(rdman->sh_rect_pool);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
33 if(rect == NULL)
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
34 return NULL;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
36 memset(rect, 0, sizeof(sh_rect_t));
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
37
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
38 mb_obj_init(rect, MBO_RECT);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
39 rect->x = x;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
40 rect->y = y;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
41 rect->w = w;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
42 rect->h = h;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
43 rect->rx = rx;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
44 rect->ry = ry;
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 40
diff changeset
45 rect->shape.free = sh_rect_free;
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
46 rect->rdman = rdman;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
47
1062
a8d20bc8ce40 Rename rdman_shape_man() to rdman_man_shape() to mean managing a shape
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
48 rdman_man_shape(rdman, (shape_t *)rect);
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
49
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
50 return (shape_t *)rect;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
51 }
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
52
1370
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
53 shape_t *
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
54 rdman_shape_rect_clone(redraw_man_t *rdman, const shape_t *_src_rect) {
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
55 const sh_rect_t *src_rect = (const sh_rect_t *)_src_rect;
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
56 sh_rect_t *new_rect;
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
57
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
58 new_rect = (sh_rect_t *)rdman_shape_rect_new(rdman,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
59 src_rect->x, src_rect->y,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
60 src_rect->w, src_rect->h,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
61 src_rect->rx, src_rect->ry);
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
62 if(new_rect == NULL)
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
63 return NULL;
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
64
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
65 sh_copy_style(rdman, (shape_t *)src_rect, (shape_t *)new_rect);
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
66
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
67 return (shape_t *)src_rect;
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
68 }
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
69
40
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
70 void sh_rect_set(shape_t *shape, co_aix x, co_aix y,
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
71 co_aix w, co_aix h, co_aix rx, co_aix ry) {
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
72 sh_rect_t *rect = (sh_rect_t *)shape;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
73
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
74 rect->x = x;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
75 rect->y = y;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
76 rect->w = w;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
77 rect->h = h;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
78 rect->rx = rx;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
79 rect->ry = ry;
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
80 }
Thinker K.F. Li <thinker@branda.to>
parents: 36
diff changeset
81
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
82 void sh_rect_transform(shape_t *shape) {
34
07c523c799f4 Fix bug of relative path command
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
83 sh_rect_t *rect = (sh_rect_t *)shape;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
84 co_aix x, y, w, h, rx, ry;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
85 co_aix (*poses)[2];
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
86 co_aix width;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
87 area_t *area;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
88 int i;
34
07c523c799f4 Fix bug of relative path command
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
89
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
90 x = rect->x;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
91 y = rect->y;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
92 w = rect->w;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
93 h = rect->h;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
94 rx = rect->rx;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
95 ry = rect->ry;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
96
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
97 poses = rect->poses;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
98
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
99 if(rect->rx != 0 && rect->ry != 0) {
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
100 poses[0][0] = x + w - rx;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
101 poses[0][1] = y;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
102 poses[1][0] = x + w;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
103 poses[1][1] = y;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
104 poses[2][0] = x + w;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
105 poses[2][1] = y + ry;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 448
diff changeset
106
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
107 poses[3][0] = x + w;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
108 poses[3][1] = y + h - ry;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
109 poses[4][0] = x + w;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
110 poses[4][1] = y + h;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
111 poses[5][0] = x + w - rx;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
112 poses[5][1] = y + h;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 448
diff changeset
113
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
114 poses[6][0] = x + rx;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
115 poses[6][1] = y + h;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
116 poses[7][0] = x;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
117 poses[7][1] = y + h;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
118 poses[8][0] = x;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
119 poses[8][1] = y + h - ry;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 448
diff changeset
120
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
121 poses[9][0] = x;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
122 poses[9][1] = y + ry;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
123 poses[10][0] = x;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
124 poses[10][1] = y;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
125 poses[11][0] = x + rx;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
126 poses[11][1] = y;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
127
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
128 for(i = 0; i < 12; i++)
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
129 coord_trans_pos(shape->coord, &poses[i][0], &poses[i][1]);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
130
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
131 geo_from_positions(shape->geo, 12, poses);
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
132 } else {
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
133 poses[0][0] = x;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
134 poses[0][1] = y;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
135 poses[1][0] = x + w;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
136 poses[1][1] = y;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
137 poses[2][0] = x + w;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
138 poses[2][1] = y + h;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
139 poses[3][0] = x;
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
140 poses[3][1] = y + h;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
141
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
142 for(i = 0; i < 4; i++)
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
143 coord_trans_pos(shape->coord, &poses[i][0], &poses[i][1]);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
144
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
145 geo_from_positions(shape->geo, 4, poses);
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
146 }
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
147
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
148 if(shape->stroke) {
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
149 area = shape->geo->cur_area;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
150 width = shape->stroke_width;
270
cd6af7da32c9 Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents: 224
diff changeset
151 area->x -= width / 2 + 0.5;
cd6af7da32c9 Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents: 224
diff changeset
152 area->y -= width / 2 + 0.5;
cd6af7da32c9 Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents: 224
diff changeset
153 area->w += width + 1;
cd6af7da32c9 Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents: 224
diff changeset
154 area->h += width + 1;
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
155 }
34
07c523c799f4 Fix bug of relative path command
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
156 }
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
157
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 270
diff changeset
158 void sh_rect_draw(shape_t *shape, mbe_t *cr) {
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
159 sh_rect_t *rect = (sh_rect_t *)shape;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
160 int i;
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
161 co_aix (*poses)[2];
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
162
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
163 poses = rect->poses;
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
164 if(rect->rx != 0 && rect->ry != 0) {
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 270
diff changeset
165 mbe_move_to(cr, poses[11][0], poses[11][1]);
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
166 for(i = 0; i < 12; i += 3) {
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 270
diff changeset
167 mbe_line_to(cr, poses[i][0], poses[i][1]);
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 270
diff changeset
168 mbe_curve_to(cr,
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
169 poses[i + 1][0], poses[i + 1][1],
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
170 poses[i + 1][0], poses[i + 1][1],
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
171 poses[i + 2][0], poses[i + 2][1]);
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
172 }
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
173 } else {
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 270
diff changeset
174 mbe_move_to(cr, poses[3][0], poses[3][1]);
36
51a20f240ce3 short-cut for no-rounded rectangle
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
175 for(i = 0; i < 4; i++)
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 270
diff changeset
176 mbe_line_to(cr, poses[i][0], poses[i][1]);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
177 }
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 34
diff changeset
178 }