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