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