Skip to content

Instantly share code, notes, and snippets.

@oblitum
Last active October 24, 2017 09:52
Show Gist options
  • Save oblitum/94350d0651a1d91d8c80297f950d399b to your computer and use it in GitHub Desktop.
Save oblitum/94350d0651a1d91d8c80297f950d399b to your computer and use it in GitHub Desktop.
nature invented it first
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="author" content="Francisco Lopes">
<link href="main.css" rel="stylesheet">
<title>nature invented it first</title>
</head>
<body>
<div style="text-align:center;">
<canvas id="output" width="600" height="600"></canvas>
<div id="controls"></div>
</div>
<script type="text/javascript" src="main.min.js"></script>
</body>
</html>
body {
margin: 40px;
background-color: black;
}
#controls > div {
display: inline-block;
margin-right: 5px;
}
input[type=range] {
/*removes default webkit styles*/
-webkit-appearance: none;
/*fix for FF unable to apply focus style bug */
border: 1px solid transparent;
/*required for proper track sizing in FF*/
width: 600px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 600px;
height: 3px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
margin-top: -4px;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ccc;
}
input[type=range]::-moz-range-track {
width: 600px;
height: 3px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid transparent;
outline-offset: -1px;
}
input[type=range]::-ms-track {
width: 600px;
height: 3px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color: transparent;
border-width: 6px 0;
/*remove default tick marks*/
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: #777;
border-radius: 10px;
}
input[type=range]::-ms-fill-upper {
background: #ddd;
border-radius: 10px;
}
input[type=range]::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
input[type=range]:focus::-ms-fill-lower {
background: #888;
}
input[type=range]:focus::-ms-fill-upper {
background: #ccc;
}
label {
display: inline-block;
color: white;
}
var PS={};(function(exports){"use strict";exports.slice=function(s){return function(e){return function(l){return l.slice(s,e);};};};exports.take=function(n){return function(l){return n<1?[]:l.slice(0,n);};};})(PS["Data.Array"]=PS["Data.Array"]||{});(function(exports){"use strict";exports.foldrArray=function(f){return function(init){return function(xs){var acc=init;var len=xs.length;for(var i=len-1;i>=0;i--){acc=f(xs[i])(acc);}
return acc;};};};exports.foldlArray=function(f){return function(init){return function(xs){var acc=init;var len=xs.length;for(var i=0;i<len;i++){acc=f(acc)(xs[i]);}
return acc;};};};})(PS["Data.Foldable"]=PS["Data.Foldable"]||{});(function(exports){"use strict";exports.arrayMap=function(f){return function(arr){var l=arr.length;var result=new Array(l);for(var i=0;i<l;i++){result[i]=f(arr[i]);}
return result;};};})(PS["Data.Functor"]=PS["Data.Functor"]||{});(function(exports){"use strict";var Semigroupoid=function(compose){this.compose=compose;};var semigroupoidFn=new Semigroupoid(function(f){return function(g){return function(x){return f(g(x));};};});var compose=function(dict){return dict.compose;};exports["Semigroupoid"]=Semigroupoid;exports["compose"]=compose;exports["semigroupoidFn"]=semigroupoidFn;})(PS["Control.Semigroupoid"]=PS["Control.Semigroupoid"]||{});(function(exports){"use strict";var Control_Semigroupoid=PS["Control.Semigroupoid"];var Category=function(__superclass_Control$dotSemigroupoid$dotSemigroupoid_0,id){this["__superclass_Control.Semigroupoid.Semigroupoid_0"]=__superclass_Control$dotSemigroupoid$dotSemigroupoid_0;this.id=id;};var id=function(dict){return dict.id;};var categoryFn=new Category(function(){return Control_Semigroupoid.semigroupoidFn;},function(x){return x;});exports["Category"]=Category;exports["id"]=id;exports["categoryFn"]=categoryFn;})(PS["Control.Category"]=PS["Control.Category"]||{});(function(exports){"use strict";var Control_Category=PS["Control.Category"];var flip=function(f){return function(b){return function(a){return f(a)(b);};};};var $$const=function(a){return function(v){return a;};};var apply=function(f){return function(x){return f(x);};};exports["apply"]=apply;exports["const"]=$$const;exports["flip"]=flip;})(PS["Data.Function"]=PS["Data.Function"]||{});(function(exports){"use strict";exports.unit={};})(PS["Data.Unit"]=PS["Data.Unit"]||{});(function(exports){"use strict";exports.showIntImpl=function(n){return n.toString();};exports.showNumberImpl=function(n){var str=n.toString();return isNaN(str+".0")?str:str+".0";};})(PS["Data.Show"]=PS["Data.Show"]||{});(function(exports){"use strict";var $foreign=PS["Data.Show"];var Show=function(show){this.show=show;};var showNumber=new Show($foreign.showNumberImpl);var showInt=new Show($foreign.showIntImpl);var show=function(dict){return dict.show;};exports["Show"]=Show;exports["show"]=show;exports["showInt"]=showInt;exports["showNumber"]=showNumber;})(PS["Data.Show"]=PS["Data.Show"]||{});(function(exports){"use strict";var $foreign=PS["Data.Unit"];var Data_Show=PS["Data.Show"];exports["unit"]=$foreign.unit;})(PS["Data.Unit"]=PS["Data.Unit"]||{});(function(exports){"use strict";var $foreign=PS["Data.Functor"];var Data_Function=PS["Data.Function"];var Data_Unit=PS["Data.Unit"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Functor=function(map){this.map=map;};var map=function(dict){return dict.map;};var $$void=function(dictFunctor){return map(dictFunctor)(Data_Function["const"](Data_Unit.unit));};var functorArray=new Functor($foreign.arrayMap);exports["Functor"]=Functor;exports["map"]=map;exports["void"]=$$void;exports["functorArray"]=functorArray;})(PS["Data.Functor"]=PS["Data.Functor"]||{});(function(exports){"use strict";var $foreign=PS["Control.Apply"];var Data_Functor=PS["Data.Functor"];var Data_Function=PS["Data.Function"];var Control_Category=PS["Control.Category"];var Apply=function(__superclass_Data$dotFunctor$dotFunctor_0,apply){this["__superclass_Data.Functor.Functor_0"]=__superclass_Data$dotFunctor$dotFunctor_0;this.apply=apply;};var apply=function(dict){return dict.apply;};var applySecond=function(dictApply){return function(a){return function(b){return apply(dictApply)(Data_Functor.map(dictApply["__superclass_Data.Functor.Functor_0"]())(Data_Function["const"](Control_Category.id(Control_Category.categoryFn)))(a))(b);};};};var lift2=function(dictApply){return function(f){return function(a){return function(b){return apply(dictApply)(Data_Functor.map(dictApply["__superclass_Data.Functor.Functor_0"]())(f)(a))(b);};};};};exports["Apply"]=Apply;exports["apply"]=apply;exports["applySecond"]=applySecond;exports["lift2"]=lift2;})(PS["Control.Apply"]=PS["Control.Apply"]||{});(function(exports){"use strict";var Control_Apply=PS["Control.Apply"];var Data_Functor=PS["Data.Functor"];var Data_Unit=PS["Data.Unit"];var Applicative=function(__superclass_Control$dotApply$dotApply_0,pure){this["__superclass_Control.Apply.Apply_0"]=__superclass_Control$dotApply$dotApply_0;this.pure=pure;};var pure=function(dict){return dict.pure;};var when=function(dictApplicative){return function(v){return function(v1){if(v){return v1;};if(!v){return pure(dictApplicative)(Data_Unit.unit);};throw new Error("Failed pattern match at Control.Applicative line 58, column 1 - line 58, column 16: "+[v.constructor.name,v1.constructor.name]);};};};var liftA1=function(dictApplicative){return function(f){return function(a){return Control_Apply.apply(dictApplicative["__superclass_Control.Apply.Apply_0"]())(pure(dictApplicative)(f))(a);};};};exports["Applicative"]=Applicative;exports["liftA1"]=liftA1;exports["pure"]=pure;exports["when"]=when;})(PS["Control.Applicative"]=PS["Control.Applicative"]||{});(function(exports){"use strict";exports.refEq=function(r1){return function(r2){return r1===r2;};};})(PS["Data.Eq"]=PS["Data.Eq"]||{});(function(exports){"use strict";var $foreign=PS["Data.Eq"];var Data_Unit=PS["Data.Unit"];var Data_Void=PS["Data.Void"];var Eq=function(eq){this.eq=eq;};var eqNumber=new Eq($foreign.refEq);var eqInt=new Eq($foreign.refEq);var eq=function(dict){return dict.eq;};exports["Eq"]=Eq;exports["eq"]=eq;exports["eqInt"]=eqInt;exports["eqNumber"]=eqNumber;})(PS["Data.Eq"]=PS["Data.Eq"]||{});(function(exports){"use strict";var $foreign=PS["Control.Bind"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Category=PS["Control.Category"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Bind=function(__superclass_Control$dotApply$dotApply_0,bind){this["__superclass_Control.Apply.Apply_0"]=__superclass_Control$dotApply$dotApply_0;this.bind=bind;};var bind=function(dict){return dict.bind;};exports["Bind"]=Bind;exports["bind"]=bind;})(PS["Control.Bind"]=PS["Control.Bind"]||{});(function(exports){"use strict";var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Data_Functor=PS["Data.Functor"];var Monad=function(__superclass_Control$dotApplicative$dotApplicative_0,__superclass_Control$dotBind$dotBind_1){this["__superclass_Control.Applicative.Applicative_0"]=__superclass_Control$dotApplicative$dotApplicative_0;this["__superclass_Control.Bind.Bind_1"]=__superclass_Control$dotBind$dotBind_1;};var ap=function(dictMonad){return function(f){return function(a){return Control_Bind.bind(dictMonad["__superclass_Control.Bind.Bind_1"]())(f)(function(v){return Control_Bind.bind(dictMonad["__superclass_Control.Bind.Bind_1"]())(a)(function(v1){return Control_Applicative.pure(dictMonad["__superclass_Control.Applicative.Applicative_0"]())(v(v1));});});};};};exports["Monad"]=Monad;exports["ap"]=ap;})(PS["Control.Monad"]=PS["Control.Monad"]||{});(function(exports){"use strict";exports.topInt=2147483647;exports.bottomInt=-2147483648;})(PS["Data.Bounded"]=PS["Data.Bounded"]||{});(function(exports){"use strict";exports.unsafeCompareImpl=function(lt){return function(eq){return function(gt){return function(x){return function(y){return x<y?lt:x>y?gt:eq;};};};};};})(PS["Data.Ord.Unsafe"]=PS["Data.Ord.Unsafe"]||{});(function(exports){"use strict";exports.concatString=function(s1){return function(s2){return s1+s2;};};exports.concatArray=function(xs){return function(ys){return xs.concat(ys);};};})(PS["Data.Semigroup"]=PS["Data.Semigroup"]||{});(function(exports){"use strict";var $foreign=PS["Data.Semigroup"];var Data_Unit=PS["Data.Unit"];var Data_Void=PS["Data.Void"];var Semigroup=function(append){this.append=append;};var semigroupString=new Semigroup($foreign.concatString);var semigroupArray=new Semigroup($foreign.concatArray);var append=function(dict){return dict.append;};exports["Semigroup"]=Semigroup;exports["append"]=append;exports["semigroupString"]=semigroupString;exports["semigroupArray"]=semigroupArray;})(PS["Data.Semigroup"]=PS["Data.Semigroup"]||{});(function(exports){"use strict";var Data_Eq=PS["Data.Eq"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var LT=(function(){function LT(){};LT.value=new LT();return LT;})();var GT=(function(){function GT(){};GT.value=new GT();return GT;})();var EQ=(function(){function EQ(){};EQ.value=new EQ();return EQ;})();exports["LT"]=LT;exports["GT"]=GT;exports["EQ"]=EQ;})(PS["Data.Ordering"]=PS["Data.Ordering"]||{});(function(exports){"use strict";var $foreign=PS["Data.Ord.Unsafe"];var Data_Ordering=PS["Data.Ordering"];var unsafeCompare=$foreign.unsafeCompareImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value);exports["unsafeCompare"]=unsafeCompare;})(PS["Data.Ord.Unsafe"]=PS["Data.Ord.Unsafe"]||{});(function(exports){"use strict";var $foreign=PS["Data.Ord"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_Ord_Unsafe=PS["Data.Ord.Unsafe"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Unit=PS["Data.Unit"];var Data_Void=PS["Data.Void"];var Data_Semiring=PS["Data.Semiring"];var Ord=function(__superclass_Data$dotEq$dotEq_0,compare){this["__superclass_Data.Eq.Eq_0"]=__superclass_Data$dotEq$dotEq_0;this.compare=compare;};var ordNumber=new Ord(function(){return Data_Eq.eqNumber;},Data_Ord_Unsafe.unsafeCompare);var ordInt=new Ord(function(){return Data_Eq.eqInt;},Data_Ord_Unsafe.unsafeCompare);var compare=function(dict){return dict.compare;};var max=function(dictOrd){return function(x){return function(y){var $27=compare(dictOrd)(x)(y);if($27 instanceof Data_Ordering.LT){return y;};if($27 instanceof Data_Ordering.EQ){return x;};if($27 instanceof Data_Ordering.GT){return x;};throw new Error("Failed pattern match at Data.Ord line 122, column 3 - line 125, column 12: "+[$27.constructor.name]);};};};var min=function(dictOrd){return function(x){return function(y){var $28=compare(dictOrd)(x)(y);if($28 instanceof Data_Ordering.LT){return x;};if($28 instanceof Data_Ordering.EQ){return x;};if($28 instanceof Data_Ordering.GT){return y;};throw new Error("Failed pattern match at Data.Ord line 113, column 3 - line 116, column 12: "+[$28.constructor.name]);};};};var clamp=function(dictOrd){return function(low){return function(hi){return function(x){return min(dictOrd)(hi)(max(dictOrd)(low)(x));};};};};exports["Ord"]=Ord;exports["clamp"]=clamp;exports["compare"]=compare;exports["max"]=max;exports["min"]=min;exports["ordInt"]=ordInt;exports["ordNumber"]=ordNumber;})(PS["Data.Ord"]=PS["Data.Ord"]||{});(function(exports){"use strict";var $foreign=PS["Data.Bounded"];var Data_Ord=PS["Data.Ord"];var Data_Unit=PS["Data.Unit"];var Data_Ordering=PS["Data.Ordering"];var Bounded=function(__superclass_Data$dotOrd$dotOrd_0,bottom,top){this["__superclass_Data.Ord.Ord_0"]=__superclass_Data$dotOrd$dotOrd_0;this.bottom=bottom;this.top=top;};var top=function(dict){return dict.top;};var boundedInt=new Bounded(function(){return Data_Ord.ordInt;},$foreign.bottomInt,$foreign.topInt);var bottom=function(dict){return dict.bottom;};exports["Bounded"]=Bounded;exports["bottom"]=bottom;exports["top"]=top;exports["boundedInt"]=boundedInt;})(PS["Data.Bounded"]=PS["Data.Bounded"]||{});(function(exports){"use strict";var Data_Function=PS["Data.Function"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Unit=PS["Data.Unit"];var Monoid=function(__superclass_Data$dotSemigroup$dotSemigroup_0,mempty){this["__superclass_Data.Semigroup.Semigroup_0"]=__superclass_Data$dotSemigroup$dotSemigroup_0;this.mempty=mempty;};var monoidString=new Monoid(function(){return Data_Semigroup.semigroupString;},"");var mempty=function(dict){return dict.mempty;};exports["Monoid"]=Monoid;exports["mempty"]=mempty;exports["monoidString"]=monoidString;})(PS["Data.Monoid"]=PS["Data.Monoid"]||{});(function(exports){"use strict";var Control_Alt=PS["Control.Alt"];var Control_Alternative=PS["Control.Alternative"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Control_Extend=PS["Control.Extend"];var Control_Monad=PS["Control.Monad"];var Control_MonadZero=PS["Control.MonadZero"];var Control_Plus=PS["Control.Plus"];var Data_Bounded=PS["Data.Bounded"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Functor_Invariant=PS["Data.Functor.Invariant"];var Data_Monoid=PS["Data.Monoid"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var Data_Unit=PS["Data.Unit"];var Control_Category=PS["Control.Category"];var Just=(function(){function Just(value0){this.value0=value0;};Just.create=function(value0){return new Just(value0);};return Just;})();var Nothing=(function(){function Nothing(){};Nothing.value=new Nothing();return Nothing;})();var maybe=function(v){return function(v1){return function(v2){if(v2 instanceof Nothing){return v;};if(v2 instanceof Just){return v1(v2.value0);};throw new Error("Failed pattern match at Data.Maybe line 232, column 1 - line 232, column 22: "+[v.constructor.name,v1.constructor.name,v2.constructor.name]);};};};var isNothing=maybe(true)(Data_Function["const"](false));var fromJust=function(dictPartial){return function(v){var __unused=function(dictPartial1){return function($dollar29){return $dollar29;};};return __unused(dictPartial)((function(){if(v instanceof Just){return v.value0;};throw new Error("Failed pattern match at Data.Maybe line 283, column 1 - line 283, column 21: "+[v.constructor.name]);})());};};exports["Just"]=Just;exports["Nothing"]=Nothing;exports["fromJust"]=fromJust;exports["isNothing"]=isNothing;exports["maybe"]=maybe;})(PS["Data.Maybe"]=PS["Data.Maybe"]||{});(function(exports){"use strict";var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Control_Extend=PS["Control.Extend"];var Control_Monad=PS["Control.Monad"];var Data_Bounded=PS["Data.Bounded"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Functor_Invariant=PS["Data.Functor.Invariant"];var Data_Maybe=PS["Data.Maybe"];var Data_Monoid=PS["Data.Monoid"];var Data_Ord=PS["Data.Ord"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var First=function(x){return x;};var semigroupFirst=new Data_Semigroup.Semigroup(function(v){return function(v1){if(v instanceof Data_Maybe.Just){return v;};return v1;};});var runFirst=function(v){return v;};var monoidFirst=new Data_Monoid.Monoid(function(){return semigroupFirst;},Data_Maybe.Nothing.value);exports["First"]=First;exports["runFirst"]=runFirst;exports["semigroupFirst"]=semigroupFirst;exports["monoidFirst"]=monoidFirst;})(PS["Data.Maybe.First"]=PS["Data.Maybe.First"]||{});(function(exports){"use strict";var $foreign=PS["Data.Foldable"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Plus=PS["Control.Plus"];var Data_BooleanAlgebra=PS["Data.BooleanAlgebra"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_Maybe=PS["Data.Maybe"];var Data_Maybe_First=PS["Data.Maybe.First"];var Data_Maybe_Last=PS["Data.Maybe.Last"];var Data_Monoid=PS["Data.Monoid"];var Data_Monoid_Additive=PS["Data.Monoid.Additive"];var Data_Monoid_Conj=PS["Data.Monoid.Conj"];var Data_Monoid_Disj=PS["Data.Monoid.Disj"];var Data_Monoid_Dual=PS["Data.Monoid.Dual"];var Data_Monoid_Endo=PS["Data.Monoid.Endo"];var Data_Monoid_Multiplicative=PS["Data.Monoid.Multiplicative"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Semiring=PS["Data.Semiring"];var Data_Unit=PS["Data.Unit"];var Control_Alt=PS["Control.Alt"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Control_Category=PS["Control.Category"];var Data_Semigroup=PS["Data.Semigroup"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Foldable=function(foldMap,foldl,foldr){this.foldMap=foldMap;this.foldl=foldl;this.foldr=foldr;};var foldr=function(dict){return dict.foldr;};var traverse_=function(dictApplicative){return function(dictFoldable){return function(f){return foldr(dictFoldable)(function($164){return Control_Apply.applySecond(dictApplicative["__superclass_Control.Apply.Apply_0"]())(f($164));})(Control_Applicative.pure(dictApplicative)(Data_Unit.unit));};};};var for_=function(dictApplicative){return function(dictFoldable){return Data_Function.flip(traverse_(dictApplicative)(dictFoldable));};};var foldl=function(dict){return dict.foldl;};var intercalate=function(dictFoldable){return function(dictMonoid){return function(sep){return function(xs){var go=function(v){return function(x){if(v.init){return{init:false,acc:x};};return{init:false,acc:Data_Semigroup.append(dictMonoid["__superclass_Data.Semigroup.Semigroup_0"]())(v.acc)(Data_Semigroup.append(dictMonoid["__superclass_Data.Semigroup.Semigroup_0"]())(sep)(x))};};};return(foldl(dictFoldable)(go)({init:true,acc:Data_Monoid.mempty(dictMonoid)})(xs)).acc;};};};};var foldableMaybe=new Foldable(function(dictMonoid){return function(f){return function(v){if(v instanceof Data_Maybe.Nothing){return Data_Monoid.mempty(dictMonoid);};if(v instanceof Data_Maybe.Just){return f(v.value0);};throw new Error("Failed pattern match at Data.Foldable line 132, column 3 - line 132, column 30: "+[f.constructor.name,v.constructor.name]);};};},function(v){return function(z){return function(v1){if(v1 instanceof Data_Maybe.Nothing){return z;};if(v1 instanceof Data_Maybe.Just){return v(z)(v1.value0);};throw new Error("Failed pattern match at Data.Foldable line 130, column 3 - line 130, column 25: "+[v.constructor.name,z.constructor.name,v1.constructor.name]);};};},function(v){return function(z){return function(v1){if(v1 instanceof Data_Maybe.Nothing){return z;};if(v1 instanceof Data_Maybe.Just){return v(v1.value0)(z);};throw new Error("Failed pattern match at Data.Foldable line 128, column 3 - line 128, column 25: "+[v.constructor.name,z.constructor.name,v1.constructor.name]);};};});var foldMapDefaultR=function(dictFoldable){return function(dictMonoid){return function(f){return function(xs){return foldr(dictFoldable)(function(x){return function(acc){return Data_Semigroup.append(dictMonoid["__superclass_Data.Semigroup.Semigroup_0"]())(f(x))(acc);};})(Data_Monoid.mempty(dictMonoid))(xs);};};};};var foldableArray=new Foldable(function(dictMonoid){return foldMapDefaultR(foldableArray)(dictMonoid);},$foreign.foldlArray,$foreign.foldrArray);var foldMap=function(dict){return dict.foldMap;};var fold=function(dictFoldable){return function(dictMonoid){return foldMap(dictFoldable)(dictMonoid)(Control_Category.id(Control_Category.categoryFn));};};exports["Foldable"]=Foldable;exports["fold"]=fold;exports["foldMap"]=foldMap;exports["foldMapDefaultR"]=foldMapDefaultR;exports["foldl"]=foldl;exports["foldr"]=foldr;exports["for_"]=for_;exports["intercalate"]=intercalate;exports["traverse_"]=traverse_;exports["foldableArray"]=foldableArray;exports["foldableMaybe"]=foldableMaybe;})(PS["Data.Foldable"]=PS["Data.Foldable"]||{});(function(exports){"use strict";exports.traverseArrayImpl=function(){function Cont(fn){this.fn=fn;}
var emptyList={};var ConsCell=function(head,tail){this.head=head;this.tail=tail;};function consList(x){return function(xs){return new ConsCell(x,xs);};}
function listToArray(list){var arr=[];while(list!==emptyList){arr.push(list.head);list=list.tail;}
return arr;}
return function(apply){return function(map){return function(pure){return function(f){var buildFrom=function(x,ys){return apply(map(consList)(f(x)))(ys);};var go=function(acc,currentLen,xs){if(currentLen===0){return acc;}else{var last=xs[currentLen-1];return new Cont(function(){return go(buildFrom(last,acc),currentLen-1,xs);});}};return function(array){var result=go(pure(emptyList),array.length,array);while(result instanceof Cont){result=result.fn();}
return map(listToArray)(result);};};};};};}();})(PS["Data.Traversable"]=PS["Data.Traversable"]||{});(function(exports){"use strict";var $foreign=PS["Data.Traversable"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Category=PS["Control.Category"];var Data_Foldable=PS["Data.Foldable"];var Data_Functor=PS["Data.Functor"];var Data_Maybe=PS["Data.Maybe"];var Data_Maybe_First=PS["Data.Maybe.First"];var Data_Maybe_Last=PS["Data.Maybe.Last"];var Data_Monoid_Additive=PS["Data.Monoid.Additive"];var Data_Monoid_Conj=PS["Data.Monoid.Conj"];var Data_Monoid_Disj=PS["Data.Monoid.Disj"];var Data_Monoid_Dual=PS["Data.Monoid.Dual"];var Data_Monoid_Multiplicative=PS["Data.Monoid.Multiplicative"];var Traversable=function(__superclass_Data$dotFoldable$dotFoldable_1,__superclass_Data$dotFunctor$dotFunctor_0,sequence,traverse){this["__superclass_Data.Foldable.Foldable_1"]=__superclass_Data$dotFoldable$dotFoldable_1;this["__superclass_Data.Functor.Functor_0"]=__superclass_Data$dotFunctor$dotFunctor_0;this.sequence=sequence;this.traverse=traverse;};var traverse=function(dict){return dict.traverse;};var sequenceDefault=function(dictTraversable){return function(dictApplicative){return function(tma){return traverse(dictTraversable)(dictApplicative)(Control_Category.id(Control_Category.categoryFn))(tma);};};};var traversableArray=new Traversable(function(){return Data_Foldable.foldableArray;},function(){return Data_Functor.functorArray;},function(dictApplicative){return sequenceDefault(traversableArray)(dictApplicative);},function(dictApplicative){return $foreign.traverseArrayImpl(Control_Apply.apply(dictApplicative["__superclass_Control.Apply.Apply_0"]()))(Data_Functor.map((dictApplicative["__superclass_Control.Apply.Apply_0"]())["__superclass_Data.Functor.Functor_0"]()))(Control_Applicative.pure(dictApplicative));});var sequence=function(dict){return dict.sequence;};exports["Traversable"]=Traversable;exports["sequence"]=sequence;exports["sequenceDefault"]=sequenceDefault;exports["traverse"]=traverse;exports["traversableArray"]=traversableArray;})(PS["Data.Traversable"]=PS["Data.Traversable"]||{});(function(exports){"use strict";var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Biapplicative=PS["Control.Biapplicative"];var Control_Biapply=PS["Control.Biapply"];var Control_Bind=PS["Control.Bind"];var Control_Comonad=PS["Control.Comonad"];var Control_Extend=PS["Control.Extend"];var Control_Lazy=PS["Control.Lazy"];var Control_Monad=PS["Control.Monad"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Bifoldable=PS["Data.Bifoldable"];var Data_Bifunctor=PS["Data.Bifunctor"];var Data_Bitraversable=PS["Data.Bitraversable"];var Data_BooleanAlgebra=PS["Data.BooleanAlgebra"];var Data_Bounded=PS["Data.Bounded"];var Data_Eq=PS["Data.Eq"];var Data_Foldable=PS["Data.Foldable"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Functor_Invariant=PS["Data.Functor.Invariant"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Maybe=PS["Data.Maybe"];var Data_Maybe_First=PS["Data.Maybe.First"];var Data_Monoid=PS["Data.Monoid"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_CommutativeRing=PS["Data.CommutativeRing"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Semiring=PS["Data.Semiring"];var Data_Show=PS["Data.Show"];var Data_Traversable=PS["Data.Traversable"];var Data_Unit=PS["Data.Unit"];var Tuple=(function(){function Tuple(value0,value1){this.value0=value0;this.value1=value1;};Tuple.create=function(value0){return function(value1){return new Tuple(value0,value1);};};return Tuple;})();var snd=function(v){return v.value1;};var fst=function(v){return v.value0;};exports["Tuple"]=Tuple;exports["fst"]=fst;exports["snd"]=snd;})(PS["Data.Tuple"]=PS["Data.Tuple"]||{});(function(exports){"use strict";exports.unfoldrArrayImpl=function(isNothing){return function(fromJust){return function(fst){return function(snd){return function(f){return function(b){var result=[];while(true){var maybe=f(b);if(isNothing(maybe))return result;var tuple=fromJust(maybe);result.push(fst(tuple));b=snd(tuple);}};};};};};};})(PS["Data.Unfoldable"]=PS["Data.Unfoldable"]||{});(function(exports){"use strict";exports.unsafePartial=function(f){return f();};})(PS["Partial.Unsafe"]=PS["Partial.Unsafe"]||{});(function(exports){"use strict";var $foreign=PS["Partial.Unsafe"];var Partial=PS["Partial"];exports["unsafePartial"]=$foreign.unsafePartial;})(PS["Partial.Unsafe"]=PS["Partial.Unsafe"]||{});(function(exports){"use strict";var $foreign=PS["Data.Unfoldable"];var Prelude=PS["Prelude"];var Data_Maybe=PS["Data.Maybe"];var Data_Traversable=PS["Data.Traversable"];var Data_Tuple=PS["Data.Tuple"];var Partial_Unsafe=PS["Partial.Unsafe"];var Data_Ord=PS["Data.Ord"];var Data_Ring=PS["Data.Ring"];var Data_Function=PS["Data.Function"];var Data_Unit=PS["Data.Unit"];var Unfoldable=function(unfoldr){this.unfoldr=unfoldr;};var unfoldr=function(dict){return dict.unfoldr;};var unfoldableArray=new Unfoldable($foreign.unfoldrArrayImpl(Data_Maybe.isNothing)(Partial_Unsafe.unsafePartial(function(dictPartial){return Data_Maybe.fromJust(dictPartial);}))(Data_Tuple.fst)(Data_Tuple.snd));var replicate=function(dictUnfoldable){return function(n){return function(v){var step=function(i){var $7=i<=0;if($7){return Data_Maybe.Nothing.value;};if(!$7){return new Data_Maybe.Just(new Data_Tuple.Tuple(v,i-1));};throw new Error("Failed pattern match at Data.Unfoldable line 58, column 7 - line 59, column 34: "+[$7.constructor.name]);};return unfoldr(dictUnfoldable)(step)(n);};};};var replicateA=function(dictApplicative){return function(dictUnfoldable){return function(dictTraversable){return function(n){return function(m){return Data_Traversable.sequence(dictTraversable)(dictApplicative)(replicate(dictUnfoldable)(n)(m));};};};};};exports["Unfoldable"]=Unfoldable;exports["replicate"]=replicate;exports["replicateA"]=replicateA;exports["unfoldr"]=unfoldr;exports["unfoldableArray"]=unfoldableArray;})(PS["Data.Unfoldable"]=PS["Data.Unfoldable"]||{});(function(exports){"use strict";var otherwise=true;exports["otherwise"]=otherwise;})(PS["Data.Boolean"]=PS["Data.Boolean"]||{});(function(exports){"use strict";var $foreign=PS["Data.Array"];var Prelude=PS["Prelude"];var Control_Alt=PS["Control.Alt"];var Control_Alternative=PS["Control.Alternative"];var Control_Lazy=PS["Control.Lazy"];var Data_Foldable=PS["Data.Foldable"];var Data_Maybe=PS["Data.Maybe"];var Data_Traversable=PS["Data.Traversable"];var Data_Tuple=PS["Data.Tuple"];var Data_Unfoldable=PS["Data.Unfoldable"];var Partial_Unsafe=PS["Partial.Unsafe"];var Data_Function=PS["Data.Function"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Ord=PS["Data.Ord"];var Data_Eq=PS["Data.Eq"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Control_Apply=PS["Control.Apply"];var Data_Functor=PS["Data.Functor"];var Control_Applicative=PS["Control.Applicative"];var Data_Boolean=PS["Data.Boolean"];var Data_Semiring=PS["Data.Semiring"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Control_Bind=PS["Control.Bind"];var Data_Semigroup=PS["Data.Semigroup"];var Control_Category=PS["Control.Category"];exports["take"]=$foreign.take;})(PS["Data.Array"]=PS["Data.Array"]||{});(function(exports){"use strict";exports.fromNumberImpl=function(just){return function(nothing){return function(n){return(n|0)===n?just(n):nothing;};};};exports.toNumber=function(n){return n;};})(PS["Data.Int"]=PS["Data.Int"]||{});(function(exports){"use strict";exports.cos=Math.cos;exports.log=Math.log;exports.remainder=function(n){return function(m){return n%m;};};exports.round=Math.round;exports.sin=Math.sin;exports.sqrt=Math.sqrt;exports.pi=Math.PI;})(PS["Math"]=PS["Math"]||{});(function(exports){"use strict";var $foreign=PS["Math"];exports["cos"]=$foreign.cos;exports["log"]=$foreign.log;exports["pi"]=$foreign.pi;exports["remainder"]=$foreign.remainder;exports["round"]=$foreign.round;exports["sin"]=$foreign.sin;exports["sqrt"]=$foreign.sqrt;})(PS["Math"]=PS["Math"]||{});(function(exports){"use strict";var $foreign=PS["Data.Int"];var Data_Boolean=PS["Data.Boolean"];var Data_BooleanAlgebra=PS["Data.BooleanAlgebra"];var Data_Bounded=PS["Data.Bounded"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_Int_Bits=PS["Data.Int.Bits"];var Data_Maybe=PS["Data.Maybe"];var Data_Ord=PS["Data.Ord"];var $$Math=PS["Math"];var Partial_Unsafe=PS["Partial.Unsafe"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var fromNumber=$foreign.fromNumberImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);var unsafeClamp=function(x){if(x>=$foreign.toNumber(Data_Bounded.top(Data_Bounded.boundedInt))){return Data_Bounded.top(Data_Bounded.boundedInt);};if(x<=$foreign.toNumber(Data_Bounded.bottom(Data_Bounded.boundedInt))){return Data_Bounded.bottom(Data_Bounded.boundedInt);};if(Data_Boolean.otherwise){return Partial_Unsafe.unsafePartial(function(dictPartial){return Data_Maybe.fromJust(dictPartial)(fromNumber(x));});};throw new Error("Failed pattern match at Data.Int line 64, column 1 - line 67, column 56: "+[x.constructor.name]);};var round=function($3){return unsafeClamp($$Math.round($3));};exports["fromNumber"]=fromNumber;exports["round"]=round;exports["toNumber"]=$foreign.toNumber;})(PS["Data.Int"]=PS["Data.Int"]||{});(function(exports){"use strict";var Prelude=PS["Prelude"];var Data_Array=PS["Data.Array"];var Data_Either=PS["Data.Either"];var Data_Foldable=PS["Data.Foldable"];var Data_Int=PS["Data.Int"];var Data_Int_Bits=PS["Data.Int.Bits"];var Data_Maybe=PS["Data.Maybe"];var Data_String=PS["Data.String"];var Data_String_Regex=PS["Data.String.Regex"];var $$Math=PS["Math"];var Partial_Unsafe=PS["Partial.Unsafe"];var Data_Show=PS["Data.Show"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Eq=PS["Data.Eq"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_EuclideanRing=PS["Data.EuclideanRing"];var Data_Semiring=PS["Data.Semiring"];var Data_Ring=PS["Data.Ring"];var Data_Ord=PS["Data.Ord"];var Data_Boolean=PS["Data.Boolean"];var Data_Function=PS["Data.Function"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Control_Bind=PS["Control.Bind"];var Data_Functor=PS["Data.Functor"];var Control_Applicative=PS["Control.Applicative"];var HSLA=(function(){function HSLA(value0,value1,value2,value3){this.value0=value0;this.value1=value1;this.value2=value2;this.value3=value3;};HSLA.create=function(value0){return function(value1){return function(value2){return function(value3){return new HSLA(value0,value1,value2,value3);};};};};return HSLA;})();var modPos=function(x){return function(y){return $$Math.remainder($$Math.remainder(x)(y)+y)(y);};};var hsla=function(h){return function(s){return function(l){return function(a){var s$prime=Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(s);var l$prime=Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(l);var h$prime=modPos(h)(360.0);var a$prime=Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(a);return new HSLA(h$prime,s$prime,l$prime,a$prime);};};};};var hsl=function(h){return function(s){return function(l){return hsla(h)(s)(l)(1.0);};};};var white=hsl(0.0)(0.0)(1.0);var cssStringHSLA=function(v){var toString=function(n){return Data_Function.apply(Data_Show.show(Data_Show.showNumber))(Data_Int.toNumber(Data_Int.round(100.0*n))/100.0);};var saturation=toString(v.value1*100.0)+"%";var lightness=toString(v.value2*100.0)+"%";var hue=toString(v.value0);var alpha=Data_Show.show(Data_Show.showNumber)(v.value3);var $71=v.value3===1.0;if($71){return"hsl("+(hue+(", "+(saturation+(", "+(lightness+")")))));};if(!$71){return"hsla("+(hue+(", "+(saturation+(", "+(lightness+(", "+(alpha+")")))))));};throw new Error("Failed pattern match at Color line 375, column 3 - line 379, column 3: "+[$71.constructor.name]);};exports["cssStringHSLA"]=cssStringHSLA;exports["hsl"]=hsl;exports["hsla"]=hsla;exports["white"]=white;})(PS["Color"]=PS["Color"]||{});(function(exports){"use strict";exports.pureE=function(a){return function(){return a;};};exports.bindE=function(a){return function(f){return function(){return f(a())();};};};})(PS["Control.Monad.Eff"]=PS["Control.Monad.Eff"]||{});(function(exports){"use strict";var $foreign=PS["Control.Monad.Eff"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Control_Monad=PS["Control.Monad"];var Data_Functor=PS["Data.Functor"];var Data_Unit=PS["Data.Unit"];var monadEff=new Control_Monad.Monad(function(){return applicativeEff;},function(){return bindEff;});var bindEff=new Control_Bind.Bind(function(){return applyEff;},$foreign.bindE);var applyEff=new Control_Apply.Apply(function(){return functorEff;},Control_Monad.ap(monadEff));var applicativeEff=new Control_Applicative.Applicative(function(){return applyEff;},$foreign.pureE);var functorEff=new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEff));exports["functorEff"]=functorEff;exports["applyEff"]=applyEff;exports["applicativeEff"]=applicativeEff;exports["bindEff"]=bindEff;exports["monadEff"]=monadEff;})(PS["Control.Monad.Eff"]=PS["Control.Monad.Eff"]||{});(function(exports){"use strict";exports.random=Math.random;})(PS["Control.Monad.Eff.Random"]=PS["Control.Monad.Eff.Random"]||{});(function(exports){"use strict";var $foreign=PS["Control.Monad.Eff.Random"];var Prelude=PS["Prelude"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Data_Int=PS["Data.Int"];var Control_Bind=PS["Control.Bind"];var Control_Applicative=PS["Control.Applicative"];var Data_Semiring=PS["Data.Semiring"];var Data_Ring=PS["Data.Ring"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Ord=PS["Data.Ord"];var randomRange=function(min){return function(max){return function __do(){var v=$foreign.random();return v*(max-min)+min;};};};exports["randomRange"]=randomRange;exports["random"]=$foreign.random;})(PS["Control.Monad.Eff.Random"]=PS["Control.Monad.Eff.Random"]||{});(function(exports){"use strict";exports.runFn3=function(fn){return function(a){return function(b){return function(c){return fn(a,b,c);};};};};})(PS["Data.Function.Uncurried"]=PS["Data.Function.Uncurried"]||{});(function(exports){"use strict";var $foreign=PS["Data.Function.Uncurried"];var Data_Unit=PS["Data.Unit"];exports["runFn3"]=$foreign.runFn3;})(PS["Data.Function.Uncurried"]=PS["Data.Function.Uncurried"]||{});(function(exports){"use strict";var Prelude=PS["Prelude"];var Control_Alt=PS["Control.Alt"];var Control_Alternative=PS["Control.Alternative"];var Control_Lazy=PS["Control.Lazy"];var Control_MonadPlus=PS["Control.MonadPlus"];var Control_MonadZero=PS["Control.MonadZero"];var Control_Plus=PS["Control.Plus"];var Data_Foldable=PS["Data.Foldable"];var Data_Generic=PS["Data.Generic"];var Data_Maybe=PS["Data.Maybe"];var Data_Monoid=PS["Data.Monoid"];var Data_Traversable=PS["Data.Traversable"];var Data_Tuple=PS["Data.Tuple"];var Data_Unfoldable=PS["Data.Unfoldable"];var Control_Apply=PS["Control.Apply"];var Data_Unit=PS["Data.Unit"];var Data_Show=PS["Data.Show"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Functor=PS["Data.Functor"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Control_Applicative=PS["Control.Applicative"];var Control_Bind=PS["Control.Bind"];var Control_Monad=PS["Control.Monad"];var Data_Ring=PS["Data.Ring"];var Data_Boolean=PS["Data.Boolean"];var Data_Semiring=PS["Data.Semiring"];var Data_BooleanAlgebra=PS["Data.BooleanAlgebra"];var Control_Category=PS["Control.Category"];var Nil=(function(){function Nil(){};Nil.value=new Nil();return Nil;})();var Cons=(function(){function Cons(value0,value1){this.value0=value0;this.value1=value1;};Cons.create=function(value0){return function(value1){return new Cons(value0,value1);};};return Cons;})();var singleton=function(a){return new Cons(a,Nil.value);};var semigroupList=new Data_Semigroup.Semigroup(function(v){return function(ys){if(v instanceof Nil){return ys;};if(v instanceof Cons){return new Cons(v.value0,Data_Semigroup.append(semigroupList)(v.value1)(ys));};throw new Error("Failed pattern match at Data.List line 719, column 3 - line 719, column 21: "+[v.constructor.name,ys.constructor.name]);};});var monoidList=new Data_Monoid.Monoid(function(){return semigroupList;},Nil.value);var foldableList=new Data_Foldable.Foldable(function(dictMonoid){return function(f){return Data_Foldable.foldl(foldableList)(function(acc){return function($387){return Data_Semigroup.append(dictMonoid["__superclass_Data.Semigroup.Semigroup_0"]())(acc)(f($387));};})(Data_Monoid.mempty(dictMonoid));};},(function(){var go=function(__copy_v){return function(__copy_b){return function(__copy_v1){var v=__copy_v;var b=__copy_b;var v1=__copy_v1;tco:while(true){if(v1 instanceof Nil){return b;};if(v1 instanceof Cons){var __tco_v=v;var __tco_b=v(b)(v1.value0);var __tco_v1=v1.value1;v=__tco_v;b=__tco_b;v1=__tco_v1;continue tco;};throw new Error("Failed pattern match at Data.List line 734, column 3 - line 737, column 49: "+[v.constructor.name,b.constructor.name,v1.constructor.name]);};};};};return go;})(),function(v){return function(b){return function(v1){if(v1 instanceof Nil){return b;};if(v1 instanceof Cons){return v(v1.value0)(Data_Foldable.foldr(foldableList)(v)(b)(v1.value1));};throw new Error("Failed pattern match at Data.List line 732, column 3 - line 732, column 20: "+[v.constructor.name,b.constructor.name,v1.constructor.name]);};};});exports["Nil"]=Nil;exports["Cons"]=Cons;exports["singleton"]=singleton;exports["semigroupList"]=semigroupList;exports["monoidList"]=monoidList;exports["foldableList"]=foldableList;})(PS["Data.List"]=PS["Data.List"]||{});(function(exports){"use strict";exports.removeChildren=function(target){return function(){var el=document.getElementById(target);while(el.firstChild){el.removeChild(el.firstChild);}};};exports.appendComponent=function(target){return function(el){return function(){document.getElementById(target).appendChild(el);};};};function getUniqueID(){if(window.flareID===undefined){window.flareID=0;}
window.flareID=window.flareID+1;return"flare-component-"+window.flareID.toString();}
function createComponent(inputType,elementCallback,eventType,eventListener){return function(label){return function(initial){return function(send){return function(){var uid=getUniqueID();var el=elementCallback(initial);el.className="flare-input-"+inputType;el.id=uid;var div=document.createElement("div");div.className="flare-input";if(label!==""){var labelEl=document.createElement("label");labelEl.htmlFor=uid;labelEl.appendChild(document.createTextNode(label));div.appendChild(labelEl);}
div.appendChild(el);el.addEventListener(eventType,function(e){var value=eventListener(e.target,initial);send(value)();});return div;};};};};}
function clamp(min,max,initial,value){if(isNaN(value)){return initial;}else if(value<min){return min;}else if(value>max){return max;}
return value;}
exports.cIntRange=function(type){return function(min){return function(max){return createComponent("int-"+type,function(initial){var input=document.createElement("input");input.type=type;input.min=min.toString();input.max=max.toString();input.step="1";input.value=initial.toString();return input;},"input",function(t,initial){return clamp(min,max,initial,parseInt(t.value,10));});};};};exports.cButton=function(vPressed){return function(label){return function(vDefault){return function(send){return function(){var div=document.createElement("div");div.className="flare-input";var button=document.createElement("button");button.id=getUniqueID();button.className="flare-input-button";button.appendChild(document.createTextNode(label));button.addEventListener('mousedown',function(){send(vPressed)();});button.addEventListener('mouseup',function(){send(vDefault)();});div.appendChild(button);return div;};};};};};})(PS["Flare"]=PS["Flare"]||{});(function(exports){function make(initial){var subs=[];var val=initial;var sig={subscribe:function(sub){subs.push(sub);sub(val);},get:function(){return val;},set:function(newval){val=newval;subs.forEach(function(sub){sub(newval);});}};return sig;};exports.constant=make;exports.mapSig=function(fun){return function(sig){var out=make(fun(sig.get()));sig.subscribe(function(val){out.set(fun(val));});return out;};};exports.applySig=function(fun){return function(sig){var out=make(fun.get()(sig.get()));var produce=function(){out.set(fun.get()(sig.get()));};fun.subscribe(produce);sig.subscribe(produce);return out;};};exports.foldp=function(fun){return function(seed){return function(sig){var acc=seed;var out=make(acc);sig.subscribe(function(val){acc=fun(val)(acc);out.set(acc);});return out;};};};exports.runSignal=function runSignal(sig){return function(){sig.subscribe(function(val){val();});return{};};};})(PS["Signal"]=PS["Signal"]||{});(function(exports){"use strict";var $foreign=PS["Signal"];var Prelude=PS["Prelude"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Data_Foldable=PS["Data.Foldable"];var Data_Maybe=PS["Data.Maybe"];var Data_Functor=PS["Data.Functor"];var Control_Apply=PS["Control.Apply"];var Control_Applicative=PS["Control.Applicative"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Function=PS["Data.Function"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Monoid=PS["Data.Monoid"];var functorSignal=new Data_Functor.Functor($foreign.mapSig);var applySignal=new Control_Apply.Apply(function(){return functorSignal;},$foreign.applySig);var applicativeSignal=new Control_Applicative.Applicative(function(){return applySignal;},$foreign.constant);exports["functorSignal"]=functorSignal;exports["applySignal"]=applySignal;exports["applicativeSignal"]=applicativeSignal;exports["constant"]=$foreign.constant;exports["foldp"]=$foreign.foldp;exports["runSignal"]=$foreign.runSignal;})(PS["Signal"]=PS["Signal"]||{});(function(exports){exports.channelP=function channelP(constant){return function(v){return function(){return constant(v);};};};exports.sendP=function sendP(chan,v){return function(v){return function(){chan.set(v);};};};exports.subscribe=function subscribe(chan){return chan;};})(PS["Signal.Channel"]=PS["Signal.Channel"]||{});(function(exports){"use strict";var $foreign=PS["Signal.Channel"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Prelude=PS["Prelude"];var Signal=PS["Signal"];var send=$foreign.sendP;var channel=$foreign.channelP(Signal.constant);exports["channel"]=channel;exports["send"]=send;exports["subscribe"]=$foreign.subscribe;})(PS["Signal.Channel"]=PS["Signal.Channel"]||{});(function(exports){"use strict";var $foreign=PS["Flare"];var Prelude=PS["Prelude"];var Data_Array=PS["Data.Array"];var Data_NonEmpty=PS["Data.NonEmpty"];var Data_Maybe=PS["Data.Maybe"];var Data_Maybe_First=PS["Data.Maybe.First"];var Data_Monoid=PS["Data.Monoid"];var Data_Foldable=PS["Data.Foldable"];var Data_Traversable=PS["Data.Traversable"];var Control_Apply=PS["Control.Apply"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Color=PS["Color"];var DOM=PS["DOM"];var DOM_Node_Types=PS["DOM.Node.Types"];var Signal=PS["Signal"];var Signal_Channel=PS["Signal.Channel"];var Data_Functor=PS["Data.Functor"];var Data_Semigroup=PS["Data.Semigroup"];var Control_Applicative=PS["Control.Applicative"];var Data_Function=PS["Data.Function"];var Control_Bind=PS["Control.Bind"];var Data_Show=PS["Data.Show"];var Data_Bounded=PS["Data.Bounded"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Flare=(function(){function Flare(value0,value1){this.value0=value0;this.value1=value1;};Flare.create=function(value0){return function(value1){return new Flare(value0,value1);};};return Flare;})();var UI=function(x){return x;};var runFlareWith=function(controls){return function(handler){return function(v){return function __do(){var v1=v();$foreign.removeChildren(controls)();Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableArray)($foreign.appendComponent(controls))(v1.value0)();return Signal.runSignal(Data_Functor.map(Signal.functorSignal)(handler)(v1.value1))();};};};};var liftSF=function(f){return function(v){return function __do(){var v1=v();return Data_Function.apply(Control_Applicative.pure(Control_Monad_Eff.applicativeEff))(new Flare(v1.value0,f(v1.value1)))();};};};var lift=function(msig){return Data_Function.apply(UI)(function __do(){var v=msig();return Data_Function.apply(Control_Applicative.pure(Control_Monad_Eff.applicativeEff))(new Flare([],v))();});};var functorFlare=new Data_Functor.Functor(function(f){return function(v){return new Flare(v.value0,Data_Functor.map(Signal.functorSignal)(f)(v.value1));};});var functorUI=new Data_Functor.Functor(function(f){return function(v){return Data_Function.apply(UI)(Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Functor.map(functorFlare)(f))(v));};});var foldp=function(f){return function(x0){return liftSF(Signal.foldp(f)(x0));};};var createUI=function(createComp){return function(label){return function($$default){return Data_Function.apply(UI)(function __do(){var v=Signal_Channel.channel($$default)();var v1=createComp(label)($$default)(Signal_Channel.send(v))();var signal=Signal_Channel.subscribe(v);return Data_Function.apply(Control_Applicative.pure(Control_Monad_Eff.applicativeEff))(new Flare([v1],signal))();});};};};var intSlider=function(label){return function(min){return function(max){return function($$default){return createUI($foreign.cIntRange("range")(min)(max))(label)($$default);};};};};var intSlider_=intSlider("");var button=function(label){return function(vDefault){return function(vPressed){return createUI($foreign.cButton(vPressed))(label)(vDefault);};};};var applyFlare=new Control_Apply.Apply(function(){return functorFlare;},function(v){return function(v1){return new Flare(Data_Semigroup.append(Data_Semigroup.semigroupArray)(v.value0)(v1.value0),Control_Apply.apply(Signal.applySignal)(v.value1)(v1.value1));};});var applyUI=new Control_Apply.Apply(function(){return functorUI;},function(v){return function(v1){return Data_Function.apply(UI)(Control_Apply.lift2(Control_Monad_Eff.applyEff)(Control_Apply.apply(applyFlare))(v)(v1));};});var applicativeFlare=new Control_Applicative.Applicative(function(){return applyFlare;},function(x){return new Flare([],Control_Applicative.pure(Signal.applicativeSignal)(x));});var applicativeUI=new Control_Applicative.Applicative(function(){return applyUI;},function(x){return Data_Function.apply(UI)(Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Control_Applicative.pure(applicativeFlare)(x)));});var buttons=function(dictTraversable){return function(xs){return function(toString){var toButton=function(x){return button(toString(x))(Data_Maybe.Nothing.value)(new Data_Maybe.Just(x));};return Data_Functor.map(functorUI)(function($89){return Data_Maybe_First.runFirst(Data_Foldable.foldMap(dictTraversable["__superclass_Data.Foldable.Foldable_1"]())(Data_Maybe_First.monoidFirst)(Data_Maybe_First.First)($89));})(Data_Traversable.traverse(dictTraversable)(applicativeUI)(toButton)(xs));};};};exports["button"]=button;exports["buttons"]=buttons;exports["foldp"]=foldp;exports["intSlider"]=intSlider;exports["intSlider_"]=intSlider_;exports["lift"]=lift;exports["liftSF"]=liftSF;exports["runFlareWith"]=runFlareWith;exports["functorFlare"]=functorFlare;exports["applyFlare"]=applyFlare;exports["applicativeFlare"]=applicativeFlare;exports["functorUI"]=functorUI;exports["applyUI"]=applyUI;exports["applicativeUI"]=applicativeUI;})(PS["Flare"]=PS["Flare"]||{});(function(exports){"use strict";exports.getCanvasElementByIdImpl=function(id,Just,Nothing){return function(){var el=document.getElementById(id);if(el&&el instanceof HTMLCanvasElement){return Just(el);}else{return Nothing;}};};exports.getContext2D=function(c){return function(){return c.getContext('2d');};};exports.getCanvasWidth=function(canvas){return function(){return canvas.width;};};exports.getCanvasHeight=function(canvas){return function(){return canvas.height;};};exports.setLineWidth=function(width){return function(ctx){return function(){ctx.lineWidth=width;return ctx;};};};exports.setFillStyle=function(style){return function(ctx){return function(){ctx.fillStyle=style;return ctx;};};};exports.setStrokeStyle=function(style){return function(ctx){return function(){ctx.strokeStyle=style;return ctx;};};};exports.setShadowColor=function(color){return function(ctx){return function(){ctx.shadowColor=color;return ctx;};};};exports.setShadowBlur=function(blur){return function(ctx){return function(){ctx.shadowBlur=blur;return ctx;};};};exports.setShadowOffsetX=function(offsetX){return function(ctx){return function(){ctx.shadowOffsetX=offsetX;return ctx;};};};exports.setShadowOffsetY=function(offsetY){return function(ctx){return function(){ctx.shadowOffsetY=offsetY;return ctx;};};};exports.beginPath=function(ctx){return function(){ctx.beginPath();return ctx;};};exports.stroke=function(ctx){return function(){ctx.stroke();return ctx;};};exports.fill=function(ctx){return function(){ctx.fill();return ctx;};};exports.clip=function(ctx){return function(){ctx.clip();return ctx;};};exports.lineTo=function(ctx){return function(x){return function(y){return function(){ctx.lineTo(x,y);return ctx;};};};};exports.moveTo=function(ctx){return function(x){return function(y){return function(){ctx.moveTo(x,y);return ctx;};};};};exports.closePath=function(ctx){return function(){ctx.closePath();return ctx;};};exports.arc=function(ctx){return function(a){return function(){ctx.arc(a.x,a.y,a.r,a.start,a.end);return ctx;};};};exports.rect=function(ctx){return function(r){return function(){ctx.rect(r.x,r.y,r.w,r.h);return ctx;};};};exports.scale=function(t){return function(ctx){return function(){ctx.scale(t.scaleX,t.scaleY);return ctx;};};};exports.rotate=function(angle){return function(ctx){return function(){ctx.rotate(angle);return ctx;};};};exports.translate=function(t){return function(ctx){return function(){ctx.translate(t.translateX,t.translateY);return ctx;};};};exports.clearRect=function(ctx){return function(r){return function(){ctx.clearRect(r.x,r.y,r.w,r.h);return ctx;};};};exports.font=function(ctx){return function(){return ctx.font;};};exports.setFont=function(fontspec){return function(ctx){return function(){ctx.font=fontspec;return ctx;};};};exports.fillText=function(ctx){return function(text){return function(x){return function(y){return function(){ctx.fillText(text,x,y);return ctx;};};};};};exports.save=function(ctx){return function(){ctx.save();return ctx;};};exports.restore=function(ctx){return function(){ctx.restore();return ctx;};};})(PS["Graphics.Canvas"]=PS["Graphics.Canvas"]||{});(function(exports){"use strict";var $foreign=PS["Graphics.Canvas"];var Prelude=PS["Prelude"];var Data_ArrayBuffer_Types=PS["Data.ArrayBuffer.Types"];var Data_Function_Uncurried=PS["Data.Function.Uncurried"];var Data_Maybe=PS["Data.Maybe"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Control_Monad_Eff_Exception_Unsafe=PS["Control.Monad.Eff.Exception.Unsafe"];var Data_Show=PS["Data.Show"];var Control_Bind=PS["Control.Bind"];var Control_Applicative=PS["Control.Applicative"];var Data_Function=PS["Data.Function"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Functor=PS["Data.Functor"];var withContext=function(ctx){return function(action){return function __do(){$foreign.save(ctx)();var v=action();$foreign.restore(ctx)();return v;};};};var strokePath=function(ctx){return function(path){return function __do(){$foreign.beginPath(ctx)();var v=path();$foreign.stroke(ctx)();return v;};};};var getCanvasElementById=function(elId){return Data_Function_Uncurried.runFn3($foreign.getCanvasElementByIdImpl)(elId)(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);};var fillPath=function(ctx){return function(path){return function __do(){$foreign.beginPath(ctx)();var v=path();$foreign.fill(ctx)();return v;};};};exports["fillPath"]=fillPath;exports["getCanvasElementById"]=getCanvasElementById;exports["strokePath"]=strokePath;exports["withContext"]=withContext;exports["arc"]=$foreign.arc;exports["clearRect"]=$foreign.clearRect;exports["clip"]=$foreign.clip;exports["closePath"]=$foreign.closePath;exports["fillText"]=$foreign.fillText;exports["getCanvasHeight"]=$foreign.getCanvasHeight;exports["getCanvasWidth"]=$foreign.getCanvasWidth;exports["getContext2D"]=$foreign.getContext2D;exports["lineTo"]=$foreign.lineTo;exports["moveTo"]=$foreign.moveTo;exports["rect"]=$foreign.rect;exports["rotate"]=$foreign.rotate;exports["scale"]=$foreign.scale;exports["setFillStyle"]=$foreign.setFillStyle;exports["setFont"]=$foreign.setFont;exports["setLineWidth"]=$foreign.setLineWidth;exports["setShadowBlur"]=$foreign.setShadowBlur;exports["setShadowColor"]=$foreign.setShadowColor;exports["setShadowOffsetX"]=$foreign.setShadowOffsetX;exports["setShadowOffsetY"]=$foreign.setShadowOffsetY;exports["setStrokeStyle"]=$foreign.setStrokeStyle;exports["translate"]=$foreign.translate;})(PS["Graphics.Canvas"]=PS["Graphics.Canvas"]||{});(function(exports){"use strict";var Prelude=PS["Prelude"];var Data_Maybe=PS["Data.Maybe"];var Data_Monoid=PS["Data.Monoid"];var Data_Foldable=PS["Data.Foldable"];var Control_Alt=PS["Control.Alt"];var Data_Eq=PS["Data.Eq"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var optionsString=function(v){return Data_Foldable.intercalate(Data_Foldable.foldableArray)(Data_Monoid.monoidString)(" ")([Data_Foldable.fold(Data_Foldable.foldableMaybe)(Data_Monoid.monoidString)(v.style),Data_Foldable.fold(Data_Foldable.foldableMaybe)(Data_Monoid.monoidString)(v.variant),Data_Foldable.fold(Data_Foldable.foldableMaybe)(Data_Monoid.monoidString)(v.weight)]);};var fontString=function(v){return optionsString(v.value2)+(" "+(Data_Show.show(Data_Show.showInt)(v.value1)+("px "+v.value0)));};exports["fontString"]=fontString;})(PS["Graphics.Drawing.Font"]=PS["Graphics.Drawing.Font"]||{});(function(exports){"use strict";var Prelude=PS["Prelude"];var Data_List=PS["Data.List"];var Data_Maybe=PS["Data.Maybe"];var Data_Monoid=PS["Data.Monoid"];var Data_Foldable=PS["Data.Foldable"];var Control_Alt=PS["Control.Alt"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Graphics_Canvas=PS["Graphics.Canvas"];var Graphics_Drawing_Font=PS["Graphics.Drawing.Font"];var $$Math=PS["Math"];var Color=PS["Color"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Eq=PS["Data.Eq"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Functor=PS["Data.Functor"];var Control_Applicative=PS["Control.Applicative"];var Data_Unit=PS["Data.Unit"];var Control_Bind=PS["Control.Bind"];var Data_Function=PS["Data.Function"];var Data_Semiring=PS["Data.Semiring"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Path=(function(){function Path(value0,value1){this.value0=value0;this.value1=value1;};Path.create=function(value0){return function(value1){return new Path(value0,value1);};};return Path;})();var Rectangle=(function(){function Rectangle(value0){this.value0=value0;};Rectangle.create=function(value0){return new Rectangle(value0);};return Rectangle;})();var Circle=(function(){function Circle(value0){this.value0=value0;};Circle.create=function(value0){return new Circle(value0);};return Circle;})();var Composite=(function(){function Composite(value0){this.value0=value0;};Composite.create=function(value0){return new Composite(value0);};return Composite;})();var Fill=(function(){function Fill(value0,value1){this.value0=value0;this.value1=value1;};Fill.create=function(value0){return function(value1){return new Fill(value0,value1);};};return Fill;})();var Outline=(function(){function Outline(value0,value1){this.value0=value0;this.value1=value1;};Outline.create=function(value0){return function(value1){return new Outline(value0,value1);};};return Outline;})();var Text=(function(){function Text(value0,value1,value2,value3,value4){this.value0=value0;this.value1=value1;this.value2=value2;this.value3=value3;this.value4=value4;};Text.create=function(value0){return function(value1){return function(value2){return function(value3){return function(value4){return new Text(value0,value1,value2,value3,value4);};};};};};return Text;})();var Many=(function(){function Many(value0){this.value0=value0;};Many.create=function(value0){return new Many(value0);};return Many;})();var Scale=(function(){function Scale(value0,value1){this.value0=value0;this.value1=value1;};Scale.create=function(value0){return function(value1){return new Scale(value0,value1);};};return Scale;})();var Translate=(function(){function Translate(value0,value1){this.value0=value0;this.value1=value1;};Translate.create=function(value0){return function(value1){return new Translate(value0,value1);};};return Translate;})();var Rotate=(function(){function Rotate(value0,value1){this.value0=value0;this.value1=value1;};Rotate.create=function(value0){return function(value1){return new Rotate(value0,value1);};};return Rotate;})();var Clipped=(function(){function Clipped(value0,value1){this.value0=value0;this.value1=value1;};Clipped.create=function(value0){return function(value1){return new Clipped(value0,value1);};};return Clipped;})();var WithShadow=(function(){function WithShadow(value0,value1){this.value0=value0;this.value1=value1;};WithShadow.create=function(value0){return function(value1){return new WithShadow(value0,value1);};};return WithShadow;})();var translate=function(tx){return function(ty){return Translate.create({translateX:tx,translateY:ty});};};var semigroupDrawing=new Data_Semigroup.Semigroup(function(v){return function(v1){if(v instanceof Many){return new Many(Data_Semigroup.append(Data_List.semigroupList)(v.value0)(Data_List.singleton(v1)));};if(v1 instanceof Many){return new Many(new Data_List.Cons(v,v1.value0));};return new Many(new Data_List.Cons(v,new Data_List.Cons(v1,Data_List.Nil.value)));};});var scale=function(sx){return function(sy){return Scale.create({scaleX:sx,scaleY:sy});};};var rotate=Rotate.create;var render=function(ctx){var renderShape=function(v){if(v instanceof Path&&v.value1 instanceof Data_List.Nil){return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit);};if(v instanceof Path&&v.value1 instanceof Data_List.Cons){return function __do(){Graphics_Canvas.moveTo(ctx)(v.value1.value0.x)(v.value1.value0.y)();Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_List.foldableList)(v.value1.value1)(function(p1){return Graphics_Canvas.lineTo(ctx)(p1.x)(p1.y);})();return Data_Function.apply(Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v.value0))(Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.closePath(ctx)))();};};if(v instanceof Rectangle){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.rect(ctx)(v.value0));};if(v instanceof Circle){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.arc(ctx)({x:v.value0.x,y:v.value0.y,r:v.value0.r,start:0.0,end:$$Math.pi*2.0}));};if(v instanceof Composite){return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_List.foldableList)(v.value0)(renderShape);};throw new Error("Failed pattern match at Graphics.Drawing line 313, column 3 - line 313, column 39: "+[v.constructor.name]);};var applyShadow=function(v){return function __do(){Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v.color)(function(color){return Graphics_Canvas.setShadowColor(Color.cssStringHSLA(color))(ctx);})();Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v.blur)(function(blur){return Graphics_Canvas.setShadowBlur(blur)(ctx);})();return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v.offset)(function(offset){return function __do(){Graphics_Canvas.setShadowOffsetX(offset.x)(ctx)();return Graphics_Canvas.setShadowOffsetY(offset.y)(ctx)();};})();};};var applyOutlineStyle=function(v){return function __do(){Data_Function.apply(Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v.color))(function(color){return Graphics_Canvas.setStrokeStyle(Color.cssStringHSLA(color))(ctx);})();return Data_Function.apply(Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v.lineWidth))(function(width){return Graphics_Canvas.setLineWidth(width)(ctx);})();};};var applyFillStyle=function(v){return Data_Function.apply(Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v.color))(function(color){return Graphics_Canvas.setFillStyle(Color.cssStringHSLA(color))(ctx);});};var go=function(v){if(v instanceof Fill){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){applyFillStyle(v.value1)();return Data_Function.apply(Graphics_Canvas.fillPath(ctx))(renderShape(v.value0))();}));};if(v instanceof Outline){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){applyOutlineStyle(v.value1)();return Data_Function.apply(Graphics_Canvas.strokePath(ctx))(renderShape(v.value0))();}));};if(v instanceof Many){return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_List.foldableList)(v.value0)(go);};if(v instanceof Scale){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){Graphics_Canvas.scale(v.value0)(ctx)();return go(v.value1)();}));};if(v instanceof Translate){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){Graphics_Canvas.translate(v.value0)(ctx)();return go(v.value1)();}));};if(v instanceof Rotate){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){Graphics_Canvas.rotate(v.value0)(ctx)();return go(v.value1)();}));};if(v instanceof Clipped){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){renderShape(v.value0)();Graphics_Canvas.clip(ctx)();return go(v.value1)();}));};if(v instanceof WithShadow){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){applyShadow(v.value0)();return go(v.value1)();}));};if(v instanceof Text){return Data_Function.apply(Data_Functor["void"](Control_Monad_Eff.functorEff))(Graphics_Canvas.withContext(ctx)(function __do(){Graphics_Canvas.setFont(Graphics_Drawing_Font.fontString(v.value0))(ctx)();applyFillStyle(v.value3)();return Graphics_Canvas.fillText(ctx)(v.value4)(v.value1)(v.value2)();}));};throw new Error("Failed pattern match at Graphics.Drawing line 263, column 1 - line 320, column 40: "+[v.constructor.name]);};return go;};var monoidDrawing=new Data_Monoid.Monoid(function(){return semigroupDrawing;},new Many(Data_Monoid.mempty(Data_List.monoidList)));var lineWidth=function(c){return{color:Data_Maybe.Nothing.value,lineWidth:new Data_Maybe.Just(c)};};var filled=Data_Function.flip(Fill.create);var fillColor=function(c){return{color:new Data_Maybe.Just(c)};};var circle=function(x){return function(y){return function(r){return new Circle({x:x,y:y,r:r});};};};exports["circle"]=circle;exports["fillColor"]=fillColor;exports["filled"]=filled;exports["lineWidth"]=lineWidth;exports["render"]=render;exports["rotate"]=rotate;exports["scale"]=scale;exports["translate"]=translate;exports["semigroupDrawing"]=semigroupDrawing;exports["monoidDrawing"]=monoidDrawing;})(PS["Graphics.Drawing"]=PS["Graphics.Drawing"]||{});(function(exports){exports.animationFrameP=function animationFrameP(constant){return function(now){return function(){var requestAnimFrame,cancelAnimFrame;if(window.requestAnimationFrame){requestAnimFrame=window.requestAnimationFrame;cancelAnimFrame=window.cancelAnimationFrame;}else if(window.mozRequestAnimationFrame){requestAnimFrame=window.mozRequestAnimationFrame;cancelAnimFrame=window.mozCancelAnimationFrame;}else if(window.webkitRequestAnimationFrame){requestAnimFrame=window.webkitRequestAnimationFrame;cancelAnimFrame=window.webkitCancelAnimationFrame;}else if(window.msRequestAnimationFrame){requestAnimFrame=window.msRequestAnimationFrame;cancelAnimFrame=window.msCancelAnimationFrame;}else if(window.oRequestAnimationFrame){requestAnimFrame=window.oRequestAnimationFrame;cancelAnimFrame=window.oCancelAnimationFrame;}else{requestAnimFrame=function(cb){setTimeout(function(){cb(now())},1000/60)};cancelAnimFrame=window.clearTimeout;}
var out=constant(now());requestAnimFrame(function tick(t){out.set(t);requestAnimFrame(tick);});return out;};};};})(PS["Signal.DOM"]=PS["Signal.DOM"]||{});(function(exports){function now(){var perf=typeof performance!=='undefined'?performance:null,proc=typeof process!=='undefined'?process:null;return(perf&&(perf.now||perf.webkitNow||perf.msNow||perf.oNow||perf.mozNow)||(proc&&proc.hrtime&&function(){var t=proc.hrtime();return(t[0]*1e9+t[1])/1e6;})||Date.now).call(perf);};exports.now=now;})(PS["Signal.Time"]=PS["Signal.Time"]||{});(function(exports){"use strict";var $foreign=PS["Signal.Time"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Control_Timer=PS["Control.Timer"];var Prelude=PS["Prelude"];var Signal=PS["Signal"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];exports["now"]=$foreign.now;})(PS["Signal.Time"]=PS["Signal.Time"]||{});(function(exports){"use strict";var $foreign=PS["Signal.DOM"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Control_Timer=PS["Control.Timer"];var DOM=PS["DOM"];var Prelude=PS["Prelude"];var Signal=PS["Signal"];var Signal_Time=PS["Signal.Time"];var Control_Bind=PS["Control.Bind"];var Data_Function=PS["Data.Function"];var Control_Applicative=PS["Control.Applicative"];var animationFrame=$foreign.animationFrameP(Signal.constant)(Signal_Time.now);exports["animationFrame"]=animationFrame;})(PS["Signal.DOM"]=PS["Signal.DOM"]||{});(function(exports){"use strict";var Prelude=PS["Prelude"];var Data_Array=PS["Data.Array"];var Data_Maybe=PS["Data.Maybe"];var Data_Foldable=PS["Data.Foldable"];var Data_Unfoldable=PS["Data.Unfoldable"];var Partial_Unsafe=PS["Partial.Unsafe"];var $$Math=PS["Math"];var DOM=PS["DOM"];var Control_Timer=PS["Control.Timer"];var Signal_Channel=PS["Signal.Channel"];var Signal_DOM=PS["Signal.DOM"];var Graphics_Drawing=PS["Graphics.Drawing"];var Graphics_Canvas=PS["Graphics.Canvas"];var Control_Monad_Eff=PS["Control.Monad.Eff"];var Control_Monad_Eff_Random=PS["Control.Monad.Eff.Random"];var Flare=PS["Flare"];var Flare_Drawing=PS["Flare.Drawing"];var Data_Semiring=PS["Data.Semiring"];var Data_EuclideanRing=PS["Data.EuclideanRing"];var Data_Function=PS["Data.Function"];var Data_Ring=PS["Data.Ring"];var Control_Bind=PS["Control.Bind"];var Data_Ord=PS["Data.Ord"];var Control_Applicative=PS["Control.Applicative"];var Data_Eq=PS["Data.Eq"];var Control_Apply=PS["Control.Apply"];var Data_Functor=PS["Data.Functor"];var Data_Traversable=PS["Data.Traversable"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Color=PS["Color"];var Start=(function(){function Start(){};Start.value=new Start();return Start;})();var Reset=(function(){function Reset(){};Reset.value=new Reset();return Reset;})();var scale=function(s){return function(v){return{x:s*v.x,y:s*v.y};};};var unit=function(p){return scale(1.0/Data_Function.apply($$Math.sqrt)(p.x*p.x+p.y*p.y))(p);};var rotate=function(v){return function(r){return{x:$$Math.cos(r)*v.x-$$Math.sin(r)*v.y,y:$$Math.sin(r)*v.x+$$Math.cos(r)*v.y};};};var randomFly=function(width){return function(height){return function __do(){var v=Control_Monad_Eff_Random.randomRange(-width/2.0)(width/2.0)();var v1=Control_Monad_Eff_Random.randomRange(-height/2.0)(height/2.0)();var v2=Control_Monad_Eff_Random.randomRange($$Math.pi/2.0+5.0e-2)($$Math.pi/2.0+0.1)();var v3=Control_Monad_Eff_Random.random();var p={x:v,y:v1};var v4=scale(0.5)(unit((function(){var $28=v3<0.5;if($28){return rotate(p)(v2);};if(!$28){return rotate(p)(-v2);};throw new Error("Failed pattern match at Main line 57, column 11 - line 58, column 44: "+[$28.constructor.name]);})()));return{p:p,v:v4};};};};var label=function(v){if(v instanceof Start){return"start";};if(v instanceof Reset){return"reset";};throw new Error("Failed pattern match at Main line 85, column 1 - line 86, column 1: "+[v.constructor.name]);};var isAction=function(v){return function(v1){if(v instanceof Data_Maybe.Just){return label(v.value0)===label(v1);};if(v instanceof Data_Maybe.Nothing){return false;};throw new Error("Failed pattern match at Main line 89, column 1 - line 89, column 41: "+[v.constructor.name,v1.constructor.name]);};};var view=function(model){var state=function(action){return function(n){return function(time){var $33={};for(var $34 in model){if(model.hasOwnProperty($34)){$33[$34]=model[$34];};};$33.flies=Data_Array.take(n)(model.flies);$33.time=time;$33.start=isAction(action)(Start.value);$33.reset=isAction(action)(Reset.value);return $33;};};};return Control_Apply.apply(Flare.applyUI)(Control_Apply.apply(Flare.applyUI)(Data_Functor.map(Flare.functorUI)(state)(Flare.buttons(Data_Traversable.traversableArray)([Start.value,Reset.value])(label)))(Flare.intSlider_(0)(200)(20)))(Flare.lift(Signal_DOM.animationFrame));};var resetView=function(model){var acc=function(ma){return function(mb){var $35=!mb.start||ma.reset;if($35){var $36={};for(var $37 in ma){if(ma.hasOwnProperty($37)){$36[$37]=ma[$37];};};$36.start=(ma.start||mb.start)&&!ma.reset;$36.time=0.0;return $36;};if(!$35){var $38={};for(var $39 in ma){if(ma.hasOwnProperty($39)){$38[$39]=ma[$39];};};$38.start=(ma.start||mb.start)&&!ma.reset;$38.time=ma.time-mb.time;return $38;};throw new Error("Failed pattern match at Main line 103, column 21 - line 105, column 105: "+[$35.constructor.name]);};};return Data_Function.apply(Flare.foldp(acc)(model))(view(model));};var fly=function(v){return function(t){var b=(v.p.x*v.v.x+v.p.y*v.v.y)/(v.p.x*v.p.x+v.p.y*v.p.y);var g=function(t2){return 1.0+b*t2;};var a=(v.p.x*v.v.y-v.p.y*v.v.x)/(v.p.x*v.v.x+v.p.y*v.v.y);var f=function(t2){return a*$$Math.log(g(t2));};return scale(g(t))(rotate(v.p)(f(t)));};};var drawFlies=function(origin){return function(flies){return function(time){var makeCircle=function(f){var p=fly(f)(time);return Data_Function.apply(Graphics_Drawing.filled(Graphics_Drawing.fillColor(Color.white)))(Graphics_Drawing.circle(p.x+origin.x)(p.y+origin.y)(2.0));};return Data_Foldable.foldMap(Data_Foldable.foldableArray)(Graphics_Drawing.monoidDrawing)(makeCircle)(flies);};};};var controller=function(model){return function __do(){Graphics_Canvas.clearRect(model.context)({x:0.0,y:0.0,w:model.width,h:model.height})();Data_Function.apply(Graphics_Drawing.render(model.context))(Data_Function.apply(Graphics_Drawing.filled(Graphics_Drawing.fillColor(Color.white)))(Graphics_Drawing.circle(model.width/2.0)(model.height/2.0)(10.0)))();return Data_Function.apply(Graphics_Drawing.render(model.context))(drawFlies({x:model.width/2.0,y:model.height/2.0})(model.flies)(model.time))();};};var main=function __do(){var v=Graphics_Canvas.getCanvasElementById("output")();var pcanvas=Data_Function.apply(Partial_Unsafe.unsafePartial)(function(dictPartial){return Data_Maybe.fromJust(dictPartial)(v);});var v1=Graphics_Canvas.getContext2D(pcanvas)();var v2=Graphics_Canvas.getCanvasWidth(pcanvas)();var v3=Graphics_Canvas.getCanvasHeight(pcanvas)();var v4=Data_Function.apply(Data_Unfoldable.replicateA(Control_Monad_Eff.applicativeEff)(Data_Unfoldable.unfoldableArray)(Data_Traversable.traversableArray)(200))(randomFly(v2)(v3))();return Data_Function.apply(Flare.runFlareWith("controls")(controller))(resetView({context:v1,width:v2,height:v3,flies:v4,time:0.0,start:false,reset:false}))();};exports["Start"]=Start;exports["Reset"]=Reset;exports["controller"]=controller;exports["drawFlies"]=drawFlies;exports["fly"]=fly;exports["isAction"]=isAction;exports["label"]=label;exports["main"]=main;exports["randomFly"]=randomFly;exports["resetView"]=resetView;exports["rotate"]=rotate;exports["scale"]=scale;exports["unit"]=unit;exports["view"]=view;})(PS["Main"]=PS["Main"]||{});PS["Main"].main();
module Main where
import Prelude
import Data.Array (take)
import Data.Foldable (foldMap)
import Data.Unfoldable (replicateA)
import Partial.Unsafe (unsafePartial)
import Data.Maybe (Maybe(..), fromJust)
import Math (Radians, log, cos, sin, sqrt, pi)
import DOM (DOM)
import Control.Timer (TIMER)
import Signal.Channel (CHANNEL)
import Signal.DOM (animationFrame)
import Graphics.Drawing (Point, render)
import Graphics.Canvas (CANVAS, Context2D,
getCanvasElementById, getContext2D,
getCanvasWidth, getCanvasHeight, clearRect)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Random (RANDOM, random, randomRange)
import Flare (UI, runFlareWith, lift, intSlider_, buttons, foldp)
import Flare.Drawing (Drawing, white, fillColor, filled, circle)
type Time = Number
type Velocity = Point
scale :: Number -> Point -> Point
scale s {x: x, y: y} = {x: s*x, y: s*y}
infixr 5 scale as ⋆
rotate :: Point -> Radians -> Point
rotate {x: x, y: y} r = {x: cos r * x - sin r * y, y: sin r * x + cos r * y}
infixr 6 rotate as ∠
unit :: Point -> Point
unit p = (1.0/(sqrt $ p.x*p.x + p.y*p.y)) ⋆ p
type Fly = {p :: Point, v :: Velocity}
fly :: Fly -> Time -> Point
fly {p: p, v: v} t = g t ⋆ p ∠ f t
where f t = a * log (g t)
g t = 1.0 + b * t
a = (p.x * v.y - p.y * v.x) / (p.x * v.x + p.y * v.y)
b = (p.x * v.x + p.y * v.y) / (p.x * p.x + p.y * p.y)
randomFly :: forall eff. Number -> Number -> Eff (random :: RANDOM | eff) Fly
randomFly width height = do
x <- randomRange (-width/2.0) (width/2.0)
y <- randomRange (-height/2.0) (height/2.0)
r <- randomRange (pi/2.0 + 0.05) (pi/2.0 + 0.1)
c <- random
let p = {x: x, y: y}
let v = 0.5 ⋆ unit if c < 0.5 then p ∠ r
else p ∠ -r
pure {p: p, v: v}
drawFlies :: Point -> Array Fly -> Time -> Drawing
drawFlies origin flies time = foldMap makeCircle flies
where makeCircle f = filled (fillColor white) $ circle (p.x + origin.x) (p.y + origin.y) 2.0
where p = fly f time
type Model = { context :: Context2D
, width :: Number
, height :: Number
, flies :: Array Fly
, time :: Time
, start :: Boolean
, reset :: Boolean }
controller :: forall eff. Model -> Eff (canvas :: CANVAS | eff) Unit
controller model = do
clearRect model.context {x: 0.0, y: 0.0, w: model.width, h: model.height}
render model.context $ filled (fillColor white) $
circle (model.width/2.0) (model.height/2.0) 10.0
render model.context $ drawFlies {x: model.width/2.0, y: model.height/2.0}
model.flies
model.time
data Action = Start | Reset
label :: Action -> String
label Start = "start"
label Reset = "reset"
isAction :: Maybe Action -> Action -> Boolean
isAction (Just a) b = label a == label b
isAction Nothing _ = false
view :: forall e. Model -> UI (timer :: TIMER | e) Model
view model = state <$> buttons [Start, Reset] label
<*> intSlider_ 0 200 20
<*> lift animationFrame
where state action n time = model { flies = take n model.flies
, time = time
, start = action `isAction` Start
, reset = action `isAction` Reset }
resetView :: forall e. Model -> UI (timer :: TIMER | e) Model
resetView model = foldp acc model $ view model
where acc ma mb = if not mb.start || ma.reset
then ma{start = next, time = 0.0}
else ma{start = next, time = ma.time - mb.time}
where next = (ma.start || mb.start) && not ma.reset
main :: Eff (dom :: DOM, channel :: CHANNEL, canvas :: CANVAS, timer :: TIMER, random :: RANDOM) Unit
main = do
canvas <- getCanvasElementById "output"
let pcanvas = unsafePartial $ fromJust canvas
context <- getContext2D pcanvas
width <- getCanvasWidth pcanvas
height <- getCanvasHeight pcanvas
flies <- replicateA 200 $ randomFly width height
runFlareWith "controls" controller $ resetView { context: context
, width : width
, height : height
, flies : flies
, time : 0.0
, start : false
, reset : false }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment