initial commit test with elm
This commit is contained in:
commit
1291e54a8b
2 changed files with 166 additions and 0 deletions
49
flame.elm
Normal file
49
flame.elm
Normal file
|
@ -0,0 +1,49 @@
|
|||
module Flame where
|
||||
|
||||
import Random
|
||||
|
||||
|
||||
|
||||
base03 = rgb 0 43 54
|
||||
base02 = rgb 7 54 66
|
||||
base01 = rgb 88 110 117
|
||||
base00 = rgb 101 123 131
|
||||
base0 = rgb 131 148 150
|
||||
base1 = rgb 147 161 161
|
||||
base2 = rgb 238 232 213
|
||||
base3 = rgb 253 246 227
|
||||
yellow = rgb 181 137 0
|
||||
orange = rgb 203 75 22
|
||||
red = rgb 220 50 47
|
||||
magenta = rgb 211 54 130
|
||||
violet = rgb 108 113 196
|
||||
blue = rgb 38 139 210
|
||||
cyan = rgb 42 161 152
|
||||
green = rgb 133 153 0
|
||||
|
||||
mybase = rgba 147 161 161 (2/3)
|
||||
|
||||
point = filled mybase . rect 20 20
|
||||
|
||||
background w h = filled base3 ( rect w h (div w 2,div h 2))
|
||||
|
||||
nextint n =
|
||||
let
|
||||
a = 22695477
|
||||
c = 1
|
||||
m = 2^32
|
||||
in
|
||||
(a*n + c) `rem` m
|
||||
|
||||
randlist seed k = if (k<0) then [] else (nextint seed):randlist (nextint seed) (k-1)
|
||||
randcouples seed k = if (k<0) then []
|
||||
else
|
||||
let ns = nextint seed
|
||||
nns = nextint ns
|
||||
in (ns,nns):randcouples nns (k-1)
|
||||
|
||||
scene (x,y) (w,h) =
|
||||
let modpoint (x,y) = (rem x w,rem y h)
|
||||
in collage w h $ background w h:map (point . modpoint) (randcouples (div y 10) (div x 10))
|
||||
|
||||
main = lift2 scene Mouse.position Window.dimensions
|
117
flame.html
Normal file
117
flame.html
Normal file
|
@ -0,0 +1,117 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html><head><meta charset="UTF-8"><title>Flame</title><style type="text/css">html,head,body { padding:0; margin:0; }body { font-family: helvetica, arial, sans-serif; }</style></head><body><script type="text/javascript" src="/home/y/.cabal/share/Elm-0.7/elm-runtime-0.7.js"></script><script type="text/javascript">
|
||||
try{
|
||||
|
||||
if (Elm.Flame) throw "Module name collision, 'Flame' is already defined.";
|
||||
Elm.Flame=function(){
|
||||
var $op={};
|
||||
for(Elm['i'] in Elm){eval('var '+Elm['i']+'=Elm[Elm.i];');}
|
||||
try{
|
||||
if (!(Elm.Prelude instanceof Object)) throw 'module not found';
|
||||
} catch(e) {
|
||||
throw ("Module 'Prelude' is missing. Compile with --make flag or load missing module in a separate JavaScript file.");
|
||||
}
|
||||
var hiddenVars={};
|
||||
for (Elm['i'] in Elm.Prelude) {
|
||||
if (hiddenVars[Elm['i']]) continue;
|
||||
eval('var ' + Elm['i'] + ' = Elm.Prelude[Elm.i];');}
|
||||
try{
|
||||
if (!(Elm.Random instanceof Object)) throw 'module not found';
|
||||
} catch(e) {
|
||||
throw ("Module 'Random' is missing. Compile with --make flag or load missing module in a separate JavaScript file.");
|
||||
}
|
||||
var hiddenVars={};
|
||||
for (Elm['i'] in Elm.Random) {
|
||||
if (hiddenVars[Elm['i']]) continue;
|
||||
eval('var ' + Elm['i'] + ' = Elm.Random[Elm.i];');}
|
||||
function background_18(w_24){
|
||||
return function(h_25){
|
||||
return filled(base3_7)(rect(w_24)(h_25)(['Tuple2',div(w_24)(2),div(h_25)(2)]));};}
|
||||
function nextint_19(n_26){
|
||||
return function(){
|
||||
var a_27=22695477;
|
||||
var c_28=1;
|
||||
var m_29=4294967296;
|
||||
return rem(((a_27*n_26)+c_28))(m_29);}();}
|
||||
function randlist_20(seed_30){
|
||||
return function(k_31){
|
||||
return ((compare(k_31)(0)[0] === 'LT')?['Nil']:['Cons',nextint_19(seed_30),randlist_20(nextint_19(seed_30))((k_31-1))]);};}
|
||||
function randcouples_21(seed_32){
|
||||
return function(k_33){
|
||||
return ((compare(k_33)(0)[0] === 'LT')?['Nil']:function(){
|
||||
var ns_34=nextint_19(seed_32);
|
||||
var nns_35=nextint_19(ns_34);
|
||||
return ['Cons',['Tuple2',ns_34,nns_35],randcouples_21(nns_35)((k_33-1))];}());};}
|
||||
function scene_22(a1_36){
|
||||
return function(a0_37){
|
||||
return function(){
|
||||
switch(a1_36[0]){
|
||||
case 'Tuple2':
|
||||
return function(){
|
||||
switch(a0_37[0]){
|
||||
case 'Tuple2':
|
||||
return function(){
|
||||
function modpoint_42(a0_43){
|
||||
return function(){
|
||||
switch(a0_43[0]){
|
||||
case 'Tuple2':
|
||||
return ['Tuple2',rem(a0_43[1])(a0_37[1]),rem(a0_43[2])(a0_37[2])];
|
||||
}
|
||||
throw "Non-exhaustive pattern match in case expression (Line 46, Column 26)";}();}
|
||||
return collage(a0_37[1])(a0_37[2])(['Cons',background_18(a0_37[1])(a0_37[2]),map(function(x){
|
||||
return point_17(modpoint_42(x));})(randcouples_21(div(a1_36[2])(10))(div(a1_36[1])(10)))]);}();
|
||||
}
|
||||
throw "Non-exhaustive pattern match in case expression (Line 46, Column 3)";}();
|
||||
}
|
||||
throw "Non-exhaustive pattern match in case expression (Line 46, Column 3)";}();};}
|
||||
var base03_0=rgb(0)(43)(54);
|
||||
var base02_1=rgb(7)(54)(66);
|
||||
var base01_2=rgb(88)(110)(117);
|
||||
var base00_3=rgb(101)(123)(131);
|
||||
var base0_4=rgb(131)(148)(150);
|
||||
var base1_5=rgb(147)(161)(161);
|
||||
var base2_6=rgb(238)(232)(213);
|
||||
var base3_7=rgb(253)(246)(227);
|
||||
var yellow_8=rgb(181)(137)(0);
|
||||
var orange_9=rgb(203)(75)(22);
|
||||
var red_10=rgb(220)(50)(47);
|
||||
var magenta_11=rgb(211)(54)(130);
|
||||
var violet_12=rgb(108)(113)(196);
|
||||
var blue_13=rgb(38)(139)(210);
|
||||
var cyan_14=rgb(42)(161)(152);
|
||||
var green_15=rgb(133)(153)(0);
|
||||
var mybase_16=rgba(147)(161)(161)((2/3));
|
||||
var point_17=function(x){
|
||||
return filled(mybase_16)(rect(20)(20)(x));};
|
||||
var main_23=lift2(scene_22)(Mouse.position)(Window.dimensions);
|
||||
return {$op : {},
|
||||
base03:base03_0,
|
||||
base02:base02_1,
|
||||
base01:base01_2,
|
||||
base00:base00_3,
|
||||
base0:base0_4,
|
||||
base1:base1_5,
|
||||
base2:base2_6,
|
||||
base3:base3_7,
|
||||
yellow:yellow_8,
|
||||
orange:orange_9,
|
||||
red:red_10,
|
||||
magenta:magenta_11,
|
||||
violet:violet_12,
|
||||
blue:blue_13,
|
||||
cyan:cyan_14,
|
||||
green:green_15,
|
||||
mybase:mybase_16,
|
||||
point:point_17,
|
||||
background:background_18,
|
||||
nextint:nextint_19,
|
||||
randlist:randlist_20,
|
||||
randcouples:randcouples_21,
|
||||
scene:scene_22,
|
||||
main:main_23};}();
|
||||
Elm.main=function(){
|
||||
return Elm.Flame.main;};
|
||||
} catch (e) {
|
||||
Elm.main=function() {
|
||||
var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' + '<br/><span style="color:grey">Runtime Error in Flame module:<br/>' + e + '<br/><br/>The problem may stem from an improper usage of:<br/>^</span>');
|
||||
document.body.innerHTML = Elm.Text.monospace(msg);throw e;};}</script><div id="widthChecker" style="width:100%; height:1px; position:absolute; top:-1px;"></div><div id="content"></div><script type="text/javascript">Dispatcher.initialize()</script><noscript></noscript></body></html>
|
Loading…
Reference in a new issue