/
Model.elm
104 lines (91 loc) · 3.5 KB
/
Model.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
module Model exposing (Model, init)
import Clouds.EffectView
import Clouds.Model
import Clouds.Update
import Effects
import Html exposing (Html)
import Lightning.EffectView
import Lightning.Model
import Lightning.Update
import Messages exposing (..)
import Noise.EffectView
import Noise.Model
import Time exposing (Posix)
type alias Model =
{ currentEffect : MetaEffect
, otherEffects : List MetaEffect
}
type alias Dimensions =
{ width : Float, height : Float }
type alias Flags =
{ window : Dimensions
, time : Int
}
init : Flags -> ( Model, Cmd Message )
init flags =
( { currentEffect =
NoiseEffect <|
Effects.build
{ name = "Noise"
, draw = Noise.EffectView.draw
, mods = []
, model = Noise.Model.init flags
, tick = \t m -> { m | time = Time.posixToMillis t }
, modConstructor = NoiseMod
, applyModifier = \eff _ _ -> eff
}
, otherEffects =
[ LightningEffect <|
Effects.build
{ name = "Fork Lightning"
, draw = Lightning.EffectView.draw
, mods =
[ ( Fremulation, "fremulation", .fremulation )
, ( Chaos, "chaos quotient", .chaos )
, ( Dilation, "time dilation", .dilation )
, ( Zoom, "zoominess", .zoom )
]
, model = Lightning.Model.init flags
, tick = Lightning.Update.tick
, modConstructor = LightningMod
, applyModifier =
\effect mod val ->
case mod of
Fremulation ->
Effects.updateModel effect
(\m -> { m | fremulation = val })
Chaos ->
Effects.updateModel effect
(\m -> { m | chaos = val })
Dilation ->
Effects.updateModel effect
(\m -> { m | dilation = val })
Zoom ->
Effects.updateModel effect
(\m -> { m | zoom = val })
}
, CloudEffect <|
Effects.build
{ name = "O'Keefe Clouds"
, draw = Clouds.EffectView.draw
, mods =
[ ( Extremity, "funkitude", .extremity )
, ( Speed, "speed", .speed )
]
, model = Clouds.Model.init flags
, tick = Clouds.Update.tick
, modConstructor = CloudMod
, applyModifier =
\effect mod val ->
case mod of
Extremity ->
Effects.updateModel effect
(\m -> { m | extremity = val })
Speed ->
Effects.updateModel effect
(\m -> { m | speed = val })
}
]
}
, Cmd.none
)