on cb609ea help sign in
elk/core-js/Graphics/Element.js
517 lines 16 kB history raw
1Elm.Graphics = function() {
2 for (this['i'] in Elm.List) {
3 eval('var ' + this['i'] + ' = Elm.List[this.i];');
4 }
5 var JS = Elm.JavaScript;
6 var DLeft_0 = ["DLeft"];
7 var DRight_1 = ["DRight"];
8 var DUp_2 = ["DUp"];
9 var DDown_3 = ["DDown"];
10 var DIn_4 = ["DIn"];
11 var DOut_5 = ["DOut"];
12 function Absolute_12(a1) {
13 return["Absolute", a1]
14 }
15 function Relative_13(a1) {
16 return["Relative", a1]
17 }
18 var Near_14 = ["Near"];
19 var Mid_15 = ["Mid"];
20 var Far_16 = ["Far"];
21 function Position_17(a1) {
22 return function(a2) {
23 return["Position", a1, a2]
24 }
25 }
26 function PositionTL_18(a1) {
27 return function(a2) {
28 return["PositionTL", a1, a2]
29 }
30 }
31 function PositionTR_19(a1) {
32 return function(a2) {
33 return["PositionTR", a1, a2]
34 }
35 }
36 function PositionBL_20(a1) {
37 return function(a2) {
38 return["PositionBL", a1, a2]
39 }
40 }
41 function PositionBR_21(a1) {
42 return function(a2) {
43 return["PositionBR", a1, a2]
44 }
45 }
46 function Element_37(id,e,w,h,o,c,l) {
47 return["Element", id, e, w, h, o, c, l ]
48 }
49 function EText_39(a1) {
50 return function(a2) {
51 return["EText", a1, a2]
52 }
53 }
54 function EImage_40(a1) {
55 return["EImage", JS.castStringToJSString(a1)]
56 }
57 function EVideo_41(a1) {
58 return["EVideo", JS.castStringToJSString(a1)]
59 }
60 function EFittedImage_42(a1) {
61 return["EFittedImage", JS.castStringToJSString(a1)]
62 }
63 function EFlow_43(a1) {
64 return function(a2) {
65 return["EFlow", a1, JS.castListToJSArray(a2)]
66 }
67 }
68 function ECollage_44(a1) {
69 return function(a2) {
70 return function(a3) {
71 return["ECollage", a1, a2, Value.groupForms(a3)]
72 }
73 }
74 }
75 var EEmpty_45 = ["EEmpty"];
76 function EContainer_46(a1) {
77 return function(a2) {
78 return["EContainer", a1, a2]
79 }
80 }
81 var Solid_68 = ["Solid"];
82 var Dotted_69 = ["Dotted"];
83 var Dashed_70 = ["Dashed"];
84 function Custom_71(a1) {
85 return["Custom", JS.castListToJSArray(a1)]
86 }
87 var Filled_72 = ["Filled"];
88 var Outlined_73 = ["Outlined"];
89 function CustomOutline_74(a1) {
90 return["CustomOutline", JS.castListToJSArray(a1)]
91 }
92 function Line_75(a1) {
93 return["Line", JS.castListToJSArray(a1)]
94 }
95 function Shape_78(a1) {
96 return function(a2) {
97 var points = JS.castListToJSArray(a1);
98 if (points.length > 0) { points.push(points[0]); }
99 return["Shape", points, a2];
100 }
101 }
102 function Form_84(a1) {
103 return function(a2) {
104 return function(a3) {
105 return function(a4) {
106 return["Form", a1, a2, a3, a4]
107 }
108 }
109 }
110 }
111 function FLine_85(a1) {
112 return function(a2) {
113 return function(a3) {
114 return["FLine", a1, a2, a3]
115 }
116 }
117 }
118 function FShape_86(a1) {
119 return function(a2) {
120 return function(a3) {
121 return["FShape", a1, a2, a3]
122 }
123 }
124 }
125 function FImage_87(a1) {
126 return function(a2) {
127 return function(a3) {
128 return["FImage", a1, a2, JS.castStringToJSString(a3)]
129 }
130 }
131 }
132 function FElement_88(a1) {
133 return["FElement", a1]
134 }
135 var left_6 = DLeft_0;
136 var right_7 = DRight_1;
137 var down_8 = DDown_3;
138 var up_9 = DUp_2;
139 var inward_10 = DIn_4;
140 var outward_11 = DOut_5;
141 var topLeft_22 = Position_17(Near_14)(Near_14);
142 var topRight_23 = Position_17(Far_16)(Near_14);
143 var bottomLeft_24 = Position_17(Near_14)(Far_16);
144 var bottomRight_25 = Position_17(Far_16)(Far_16);
145 var midLeft_26 = Position_17(Near_14)(Mid_15);
146 var midRight_27 = Position_17(Far_16)(Mid_15);
147 var midTop_28 = Position_17(Mid_15)(Near_14);
148 var midBottom_29 = Position_17(Mid_15)(Far_16);
149 var middle_30 = Position_17(Mid_15)(Mid_15);
150 function middleAt(a1) {
151 return function(a2) {
152 return["PositionAt", a1, a2]
153 }
154 }
155 var topLeftAt_31 = PositionTL_18;
156 var topRightAt_32 = PositionTR_19;
157 var bottomLeftAt_33 = PositionBL_20;
158 var bottomRightAt_34 = PositionBR_21;
159 var absolute_35 = Absolute_12;
160 var relative_36 = Relative_13;
161 function newElement_38(e,w,h,o,c,l) { return Element_37(Guid.guid(),e,w,h,o,c,l); }
162 function basicNewElement(e,w,h) { return Element_37(Guid.guid(),e,w,h,1,["Nothing"],["Nothing"]); }
163 var line_76 = Line_75;
164 var polygon_79 = Shape_78;
165 function sprite_96(src) {
166 return function(w) {
167 return function(h) {
168 return function(pos) {
169 return Form_84(0)(1)(pos)(FImage_87(w)(h)(src))
170 }
171 }
172 }
173 }
174 function toForm_97(pos) {
175 return function(e) {
176 return Form_84(0)(1)(pos)(FElement_88(e))
177 }
178 }
179 function width_47(w__101) {
180 return function(e) {
181 var be = e[2];
182 switch(be[0]) {
183 case "EImage":
184 case "EVideo":
185 return newElement_38(e[2],w__101,e[4] * w__101 / e[3], e[5], e[6], e[7]);
186 case "EText":
187 var p = Value.getTextSize(w__101,e[4],be[2]);
188 return newElement_38(e[2], w__101, p[1], e[5], e[6], e[7]);
189 }
190 return newElement_38(e[2], w__101, e[4], e[5], e[6], e[7]);
191 }
192 }
193 function height_48(h__108) {
194 return function(e) {
195 var be = e[2];
196 switch(be[0]) {
197 case "EImage":
198 case "EVideo":
199 return newElement_38(e[2], e[3] * h__108 / e[4], h__108, e[5], e[6], e[7]);
200 }
201 return newElement_38(e[2], e[3], h__108, e[5], e[6], e[7]);
202 }
203 }
204 function size_49(w) {
205 return function(h) {
206 return function(e) {
207 return newElement_38(e[2], w, h, e[5], e[6], e[7]);
208 }
209 }
210 }
211 function opacity_50(o) {
212 return function(e) {
213 return newElement_38(e[2], e[3], e[4], o, e[6], e[7]);
214 }
215 }
216 function color_51(c) {
217 return function(e) {
218 return newElement_38(e[2], e[3], e[4], e[5], ["Just",c], e[7]);
219 }
220 }
221 function link(lnk) {
222 return function(e) {
223 return newElement_38(e[2], e[3], e[4], e[5], e[6], ["Just", JS.castStringToJSString(lnk)]);
224 }
225 }
226 function widthOf_52(e) { return ~~e[3]; }
227 function heightOf_53(e) { return ~~e[4]; }
228 function sizeOf_54(e) { return["Tuple2", ~~e[3], ~~e[4]] }
229 function text_56(txt) {
230 var p = Value.getTextSize(0,0,txt);
231 return basicNewElement(EText_39("left")(txt), p[0], p[1])
232 }
233 function plainText(str) {
234 var txt = Value.toText(str);
235 var p = Value.getTextSize(0,0,txt);
236 return basicNewElement(EText_39("left")(txt),p[0],p[1])
237 }
238 function asText(v) {
239 var txt = Elm.Text.monospace(Value.toText(Value.show(v)));
240 var p = Value.getTextSize(0,0,txt);
241 return basicNewElement(EText_39("left")(txt),p[0],p[1])
242 }
243 function centeredText(txt) {
244 var p = Value.getTextSize(0,0,txt);
245 return basicNewElement(EText_39("center")(txt),p[0],p[1])
246 }
247 function justifiedText(txt) {
248 var p = Value.getTextSize(0,0,txt);
249 return basicNewElement(EText_39("justify")(txt),p[0],p[1])
250 }
251 function rightedText(txt) {
252 var p = Value.getTextSize(0,0,txt);
253 return basicNewElement(EText_39("right")(txt),p[0],p[1])
254 }
255 function image_57(w) {
256 return function(h) {
257 return function(src) {
258 return basicNewElement(EImage_40(src),w,h)
259 }
260 }
261 }
262 function images(srcs) {
263 var pics = Elm.Signal.constant(spacer_66(0)(0));
264 var update = Elm.Signal.lift(function(src) {
265 src = JS.castStringToJSString(src);
266 var img = new Image();
267 img.onload = function() {
268 Dispatcher.notify(pics.id,
269 image_57(this.width)(this.height)(src));
270 };
271 img.src = src;
272 })(srcs);
273 function f(x) { return function(y) { return x; } }
274 var combine = Elm.Signal.lift2(f)(pics)(update);
275 return combine;
276 }
277 function video_58(w) {
278 return function(h) {
279 return function(src) {
280 return basicNewElement(EVideo_41(src),w,h)
281 }
282 }
283 }
284 function fittedImage_59(w_147) {
285 return function(h_148) {
286 return function(s_149) {
287 return basicNewElement(EFittedImage_42(s_149),w_147,h_148)
288 }
289 }
290 }
291 function flow_60(dir_150) {
292 return function(es_151) {
293 return function() {
294 var w_152 = function() {
295 var ws_154 = map(widthOf_52)(es_151);
296 return function(case1) {
297 var case0 = case1;
298 switch(case0[0]) {
299 case "DLeft":
300 return sum(ws_154);
301 case "DRight":
302 return sum(ws_154)
303 }
304 return maximum(ws_154)
305 }(dir_150)
306 }();
307 var h_153 = function() {
308 var hs_155 = map(heightOf_53)(es_151);
309 return function(case3) {
310 var case2 = case3;
311 switch(case2[0]) {
312 case "DDown":
313 return sum(hs_155);
314 case "DUp":
315 return sum(hs_155)
316 }
317 return maximum(hs_155)
318 }(dir_150)
319 }();
320 return basicNewElement(EFlow_43(dir_150)(es_151), w_152, h_153)
321 }()
322 }
323 }
324 function above_61(e1_156) {
325 return function(e2_157) {
326 return basicNewElement(EFlow_43(DDown_3)(["Cons", e1_156, ["Cons", e2_157, ["Nil"]]]), Math.max(widthOf_52(e1_156),widthOf_52(e2_157)), heightOf_53(e1_156) + heightOf_53(e2_157));
327 }
328 }
329 function below_62(e1_158) {
330 return function(e2_159) {
331 return basicNewElement(EFlow_43(DDown_3)(["Cons", e2_159, ["Cons", e1_158, ["Nil"]]]), Math.max(widthOf_52(e1_158),widthOf_52(e2_159)), heightOf_53(e1_158) + heightOf_53(e2_159));
332 }
333 }
334 function beside_63(e1_160) {
335 return function(e2_161) {
336 return basicNewElement(EFlow_43(DRight_1)(["Cons", e1_160, ["Cons", e2_161, ["Nil"]]]), widthOf_52(e1_160) + widthOf_52(e2_161), Math.max(heightOf_53(e1_160),heightOf_53(e2_161)));
337 }
338 }
339 function layers_64(es_162) {
340 return basicNewElement(EFlow_43(DOut_5)(es_162), maximum(map(widthOf_52)(es_162)), maximum(map(heightOf_53)(es_162)))
341 }
342 function collage_65(w_163) {
343 return function(h_164) {
344 return function(forms_165) {
345 return basicNewElement(ECollage_44(w_163)(h_164)(forms_165),w_163,h_164)
346 }
347 }
348 }
349 function spacer_66(w_166) {
350 return function(h_167) {
351 return basicNewElement(EEmpty_45,w_166,h_167)
352 }
353 }
354 function container_67(w_169) {
355 return function(h_170) {
356 return function(pos_168) {
357 return function(e_171) {
358 return basicNewElement(EContainer_46(pos_168)(e_171),w_169,h_170)
359 }
360 }
361 }
362 }
363 function segment_77(p1_172) {
364 return function(p2_173) {
365 return Line_75(["Cons", p1_172, ["Cons", p2_173, ["Nil"]]])
366 }
367 }
368 function rect_80(w_174) {
369 return function(h_175) {
370 return function(pos_176) {
371 return Shape_78(["Cons", ["Tuple2", 0 - w_174 / 2, 0 - h_175 / 2],
372 ["Cons", ["Tuple2", 0 - w_174 / 2, h_175 / 2],
373 ["Cons", ["Tuple2", w_174 / 2, h_175 / 2],
374 ["Cons", ["Tuple2", w_174 / 2, 0 - h_175 / 2], ["Nil"]]]]])(pos_176)
375 }
376 }
377 }
378 function oval_81(w_177) {
379 return function(h_178) {
380 return function(pos_179) {
381 return function() {
382 var n_180 = 50;
383 return function() {
384 function f_181(i_182) {
385 return["Tuple2", w_177 / 2 * Math.cos(2 * (Math.PI / n_180) * i_182), h_178 / 2 * Math.sin(2 * (Math.PI / n_180) * i_182)];
386 }
387 return Shape_78(map(f_181)(function() {
388 var lo = 0;
389 var hi = n_180 - 1;
390 var lst = ["Nil"];
391 if(lo <= hi) {
392 do {
393 lst = ["Cons", hi, lst]
394 }while(hi-- > lo)
395 }
396 return lst
397 }()))(pos_179)
398 }()
399 }()
400 }
401 }
402 }
403 function circle_82(r_183) {
404 return oval_81(2 * r_183)(2 * r_183)
405 }
406 function ngon_83(n_184) {
407 return function(r_185) {
408 return function(pos_186) {
409 return function() {
410 var m_187 = n_184;
411 return function() {
412 function f_188(i_189) {
413 return["Tuple2", r_185 * Math.cos(2 * (Math.PI / m_187) * i_189), r_185 * Math.sin(2 * (Math.PI / m_187) * i_189)];
414 }
415 return Shape_78(map(f_188)(function() {
416 var lo = 0;
417 var hi = n_184 - 1;
418 var lst = ["Nil"];
419 if(lo <= hi) {
420 do {
421 lst = ["Cons", hi, lst]
422 }while(hi-- > lo)
423 }
424 return lst
425 }()))(pos_186)
426 }()
427 }()
428 }
429 }
430 }
431 function solid_89(clr_190) {
432 return function(ln_191) {
433 return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Solid_68)(clr_190)(ln_191))
434 }
435 }
436 function dotted_90(clr_192) {
437 return function(ln_193) {
438 return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Dotted_69)(clr_192)(ln_193))
439 }
440 }
441 function dashed_91(clr_194) {
442 return function(ln_195) {
443 return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Dashed_70)(clr_194)(ln_195))
444 }
445 }
446 function customLine_92(pattern_196) {
447 return function(clr_197) {
448 return function(ln_198) {
449 return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Custom_71(pattern_196))(clr_197)(ln_198))
450 }
451 }
452 }
453 function filled_93(clr) {
454 return function(shape) {
455 return Form_84(0)(1)(shape[2])(FShape_86(Filled_72)(clr)(shape));
456 }
457 }
458 function outlined_94(clr) {
459 return function(shape) {
460 return Form_84(0)(1)(shape[2])(FShape_86(Outlined_73)(clr)(shape));
461 }
462 }
463 function customOutline_95(pattern) {
464 return function(clr) {
465 return function(shape) {
466 return Form_84(0)(1)(shape[2])(FShape_86(CustomOutline_74(pattern))(clr)(shape));
467 }
468 }
469 }
470 function textured(src) {
471 return function(shape) {
472 return Form_84(0)(1)(shape[2])(FShape_86(["Textured",src])(null)(shape));
473 }
474 }
475 function rotate_98(t_212) {
476 return function(Form$thetascaleposform_213) {
477 return function(case5) {
478 var case0 = case5;
479 switch(case0[0]) {
480 case "Form":
481 var case1 = case0[1], case2 = case0[2], case3 = case0[3], case4 = case0[4];
482 return Form_84(t_212 + case1)(case2)(case3)(case4)
483 }
484 throw new Error("Non-exhaustive pattern match in case");
485 }(Form$thetascaleposform_213)
486 }
487 }
488 function scale_99(s) {
489 return function(form) {
490 return Form_84(form[1])(s * form[2])(form[3])(form[4])
491 }
492 }
493 function move_100(x_224) {
494 return function(y_225) {
495 return function(Form$thetascaleTuple2$pxpyform_226) {
496 return function(case7) {
497 var case0 = case7;
498 switch(case0[0]) {
499 case "Form":
500 var case1 = case0[1], case2 = case0[2], case3 = case0[3], case4 = case0[4];
501 switch(case3[0]) {
502 case "Tuple2":
503 var case5 = case3[1], case6 = case3[2];
504 return Form_84(case1)(case2)(["Tuple2", x_224 + case5, y_225 + case6])(case4)
505 }
506 break
507 }
508 throw new Error("Non-exhaustive pattern match in case");
509 }(Form$thetascaleTuple2$pxpyform_226)
510 }
511 }
512 }
513 return{left:left_6, right:right_7, down:down_8, up:up_9, inward:inward_10, outward:outward_11, topLeft:topLeft_22, topRight:topRight_23, bottomLeft:bottomLeft_24, bottomRight:bottomRight_25, midLeft:midLeft_26, midRight:midRight_27, midTop:midTop_28, midBottom:midBottom_29, middle:middle_30, middleAt:middleAt, topLeftAt:topLeftAt_31, topRightAt:topRightAt_32, bottomLeftAt:bottomLeftAt_33, bottomRightAt:bottomRightAt_34, absolute:absolute_35, relative:relative_36, width:width_47, height:height_48, size:size_49, opacity:opacity_50,
514 color:color_51, link:link, widthOf:widthOf_52, heightOf:heightOf_53, sizeOf:sizeOf_54, text:text_56, asText:asText, plainText:plainText, centeredText:centeredText, justifiedText:justifiedText, rightedText:rightedText, image:image_57, images:images, video:video_58, fittedImage:fittedImage_59, flow:flow_60, above:above_61, below:below_62, beside:beside_63, layers:layers_64, collage:collage_65, spacer:spacer_66, container:container_67, line:line_76, segment:segment_77, polygon:polygon_79, rect:rect_80, oval:oval_81, circle:circle_82, ngon:ngon_83, solid:solid_89, dotted:dotted_90, dashed:dashed_91, customLine:customLine_92, filled:filled_93,
515 outlined:outlined_94, customOutline:customOutline_95, textured:textured, sprite:sprite_96, toForm:toForm_97, rotate:rotate_98, scale:scale_99, move:move_100,
516 isWithin: Collage.insideForm}
517}();