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