Lines 1-114
Link Here
|
1 |
Index: ChangeLog |
|
|
2 |
=================================================================== |
3 |
--- ChangeLog (revision 153) |
4 |
+++ ChangeLog (revision 154) |
5 |
@@ -1,5 +1,9 @@ |
6 |
ChangeLog |
7 |
|
8 |
+ (2007/05/22) PS1 - xfig backend: added depth to opaque components |
9 |
+ to avoid them floating to the background. Suggested by Rafael |
10 |
+ Laboissiere. |
11 |
+ |
12 |
v1.8 2007/04/09 |
13 |
(2007/04/08) PS1 - portability: use 'test' instead of '[' in shell |
14 |
scripts. |
15 |
Index: src/backend_xfig.c |
16 |
=================================================================== |
17 |
--- src/backend_xfig.c (revision 153) |
18 |
+++ src/backend_xfig.c (revision 154) |
19 |
@@ -124,13 +124,13 @@ |
20 |
return n; |
21 |
} |
22 |
|
23 |
-/* do one path. First should be 1 on the very first path, else 0. */ |
24 |
-static int xfig_path(FILE *fout, potrace_curve_t *curve, trans_t t, int sign) { |
25 |
+/* do one path. */ |
26 |
+static void xfig_path(FILE *fout, potrace_curve_t *curve, trans_t t, int sign, int depth) { |
27 |
int i; |
28 |
dpoint_t *c; |
29 |
int m = curve->n; |
30 |
|
31 |
- fprintf(fout, "3 1 0 0 0 %d 50 0 20 0.000 0 0 0 %d\n", sign=='+' ? 32 : 33, npoints(curve, m)); |
32 |
+ fprintf(fout, "3 1 0 0 0 %d %d 0 20 0.000 0 0 0 %d\n", sign=='+' ? 32 : 33, depth, npoints(curve, m)); |
33 |
|
34 |
for (i=0; i<m; i++) { |
35 |
c = curve->c[i]; |
36 |
@@ -154,15 +154,43 @@ |
37 |
break; |
38 |
} |
39 |
} |
40 |
- return 0; |
41 |
} |
42 |
|
43 |
+/* render a whole tree */ |
44 |
+static void xfig_write_paths(FILE *fout, potrace_path_t *plist, trans_t t, int depth) { |
45 |
+ potrace_path_t *p, *q; |
46 |
+ |
47 |
+ for (p=plist; p; p=p->sibling) { |
48 |
+ xfig_path(fout, &p->curve, t, p->sign, depth); |
49 |
+ for (q=p->childlist; q; q=q->sibling) { |
50 |
+ xfig_path(fout, &q->curve, t, q->sign, depth >= 1 ? depth-1 : 0); |
51 |
+ } |
52 |
+ for (q=p->childlist; q; q=q->sibling) { |
53 |
+ xfig_write_paths(fout, q->childlist, t, depth >= 2 ? depth-2 : 0); |
54 |
+ } |
55 |
+ } |
56 |
+} |
57 |
+ |
58 |
+/* calculate the depth of a tree. Call with d=0. */ |
59 |
+static int xfig_get_depth(potrace_path_t *plist) { |
60 |
+ potrace_path_t *p; |
61 |
+ int max =0; |
62 |
+ int d; |
63 |
+ |
64 |
+ for (p=plist; p; p=p->sibling) { |
65 |
+ d = xfig_get_depth(p->childlist); |
66 |
+ if (d > max) { |
67 |
+ max = d; |
68 |
+ } |
69 |
+ } |
70 |
+ return max + 1; |
71 |
+} |
72 |
+ |
73 |
/* ---------------------------------------------------------------------- */ |
74 |
/* Backend. */ |
75 |
|
76 |
/* public interface for XFIG */ |
77 |
int page_xfig(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) { |
78 |
- potrace_path_t *p; |
79 |
trans_t t; |
80 |
double si, co; |
81 |
double origx = imginfo->trans.orig[0] + imginfo->lmar; |
82 |
@@ -174,6 +202,7 @@ |
83 |
pageformat_t *f; |
84 |
int i; |
85 |
int x0, y0, x1, y1; /* in xfig's coordinates */ |
86 |
+ int depth; |
87 |
|
88 |
si = sin(info.angle/180*M_PI); |
89 |
co = cos(info.angle/180*M_PI); |
90 |
@@ -220,11 +249,21 @@ |
91 |
fprintf(fout, "0 33 #%06x\n", info.fillcolor); |
92 |
fprintf(fout, "6 %d %d %d %d\n", x0-75, y1-35, x1+75, y0+35); /* bounding box */ |
93 |
|
94 |
+ /* determine depth of the tree */ |
95 |
+ depth = xfig_get_depth(plist); |
96 |
+ |
97 |
+ /* figure out appropriate xfig starting depth. Note: xfig only has 1000 depths available */ |
98 |
+ if (depth <= 40) { |
99 |
+ depth = 50; |
100 |
+ } else if (depth < 990) { |
101 |
+ depth += 10; |
102 |
+ } else { |
103 |
+ depth = 999; |
104 |
+ } |
105 |
+ |
106 |
/* write paths. Note: can never use "opticurve" with this backend - |
107 |
it just does not approximate Bezier curves closely enough. */ |
108 |
- list_forall (p, plist) { |
109 |
- xfig_path(fout, &p->curve, t, p->sign); |
110 |
- } |
111 |
+ xfig_write_paths(fout, plist, t, depth); |
112 |
|
113 |
fprintf(fout, "-6\n"); /* end bounding box */ |
114 |
|