comparison awesome_js/robert.js @ 48:b2a11435a89b laserkard

[svn r49] implemented resizing text :)
author rlm
date Sun, 31 Jan 2010 20:26:16 -0500
parents 4431dc7d4bb5
children 5eb11cf654de
comparison
equal deleted inserted replaced
47:4431dc7d4bb5 48:b2a11435a89b
1 1
2 descHash = new Object(); 2 descHash = new Object();
3 3
4 prevVal = "";
4 5
5 6
6 7
7 descHash.classic_acrylic_clear = 8 descHash.classic_acrylic_clear =
8 "<h1>The Classic LaserKard.</h1>Balanced and Complete. The original LaserKard. For those that wish to leave no stone unturned. It's all there."; 9 "<h1>The Classic LaserKard.</h1>Balanced and Complete. The original LaserKard. For those that wish to leave no stone unturned. It's all there.";
62 63
63 if (typeof values.posx != 'undefined'){posx = values.posx;} 64 if (typeof values.posx != 'undefined'){posx = values.posx;}
64 if (typeof values.posy != 'undefined'){posy = values.posy;} 65 if (typeof values.posy != 'undefined'){posy = values.posy;}
65 if (typeof values.center != 'undefined'){center = values.center;} 66 if (typeof values.center != 'undefined'){center = values.center;}
66 if (typeof values.font != 'undefined'){font = values.font;} 67 if (typeof values.font != 'undefined'){font = values.font;}
68 if (typeof values.face != 'undefined'){face = values.face;}
69 if (typeof values.width != 'undefined'){width = values.width;}
67 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;} 70 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;}
71 if (typeof values.resize != 'undefined'){resize = values.resize;}
68 } 72 }
69 73
70 74
71 } 75 }
72 76
73 77
74 78
75 79
76 function smallRedraw(style,field) 80 function smallRedraw(style,field)
77 { 81 {
82
83
78 84
79 var JSONtext = document.getElementById('formValues').innerHTML; 85 var JSONtext = document.getElementById('formValues').innerHTML;
80 var hash = new Object(); 86 var hash = new Object();
81 hash = eval('(' + JSONtext + ')'); 87 hash = eval('(' + JSONtext + ')');
82 88
83 var content = eval("hash."+field); 89 var content = eval("hash."+field);
84 90
85 content = unescape(content); 91 content = unescape(content);
92
93 if (prevVal == content){return;}
86 94
87 posx = 10; 95 posx = 10;
88 posy = 10; 96 posy = 10;
89 center = 0; 97 center = 0;
90 font = 10; 98 font = 10;
91 face = 700; 99 face = 700;
92 weirdFlip = 0; 100 weirdFlip = 0;
101 resize = 1;
102 width = 450;
93 103
94 getPosition(style, field); 104 getPosition(style, field);
95 105
106
107
108
96 target = "d_" + field; 109 target = "d_" + field;
97 110
98 111
99 var whatev = eval("typeof " + target + " != 'undefined'") 112 var whatev = eval("typeof " + target + " != 'undefined'")
100 113
101 if (whatev){eval ("{" + target + ".remove();}");} 114 if (whatev){eval ("{" + target + ".remove();}");}
102 115
103 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" ); 116 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );
104 117
105 118
106 eval ( target +".attr('stroke', '#6a6a6a');"); 119 var sizzle = eval(target+".getBBox().width;");
120
121 document.getElementById('output').innerHTML = sizzle;
122
123
124 if (resize == 1)
125
126 {
127
128
129
130
131 //base case
132 if ((sizzle) > width)
133 {
134
135 mul = .9;
136
137
138 mul = (width/sizzle);
139
140
141 font = font * mul;
142
143 //eval( target + ".scale(mul,mul)" );
144
145 eval ( target + ".remove();");
146 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );
147
148
149 }
150
151
152
153 }
154
155
156
157 var sizzle = eval(target+".getBBox().width;");
158
159 document.getElementById('output').innerHTML = sizzle;
160
161 eval ( target +".attr('stroke', '#fefefe');");
162 //eval ( target +".attr('stroke', '#fbafcd');");
163
107 eval ( target +".attr('fill', 'none');"); 164 eval ( target +".attr('fill', 'none');");
165
166
108 167
109 168
110 if (center == 1) 169 if (center == 1)
111 { 170 {
112 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);"); 171 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");
120 eval(target+".translate(0, -490);"); 179 eval(target+".translate(0, -490);");
121 eval(target+".rotate(90,0,0);"); 180 eval(target+".rotate(90,0,0);");
122 } 181 }
123 182
124 183
184
185 prevVal = content;
125 186
126 187
127 188
128 } 189 }
129 190
167 smallRedraw("arrow","Occupation"); 228 smallRedraw("arrow","Occupation");
168 smallRedraw("arrow","Company"); 229 smallRedraw("arrow","Company");
169 230
170 231
171 d_lineArt = raphe.path("M 2 272 L 258 272"); 232 d_lineArt = raphe.path("M 2 272 L 258 272");
172 d_lineArt.attr('stroke', '#6a6a6a'); 233 d_lineArt.attr('stroke', '#fefefe');
173 234
174 } 235 }
175 236
176 237
177 if (style == "classic") 238 if (style == "classic")
178 { 239 {
199 smallRedraw("direct","Company"); 260 smallRedraw("direct","Company");
200 smallRedraw("direct","Phone"); 261 smallRedraw("direct","Phone");
201 smallRedraw("direct","Website"); 262 smallRedraw("direct","Website");
202 263
203 d_lineArt = raphe.path("M 350 165 L 512 165 M 350 173 L 512 173 M 350 181 L 512 181 M 350 189 L 512 189 M 350 197 L 512 197 M 350 213 L 512 213 M 350 205 L 512 205 M 350 221 L 512 221"); 264 d_lineArt = raphe.path("M 350 165 L 512 165 M 350 173 L 512 173 M 350 181 L 512 181 M 350 189 L 512 189 M 350 197 L 512 197 M 350 213 L 512 213 M 350 205 L 512 205 M 350 221 L 512 221");
204 d_lineArt.attr('stroke', '#6a6a6a'); 265 d_lineArt.attr('stroke', '#fefefe');
205 266
206 267
207 268
208 } 269 }
209 270
210 271
211 272
212 273
213 274
214 } 275 }
215 276
216 277