-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIncrementalMandelbrot.elm
61 lines (42 loc) · 1.11 KB
/
IncrementalMandelbrot.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
module IncrementalMandelbrot exposing (Model, init, Msg, update, view)
import Mandelbrot
import Task
import Html exposing (..)
import Process
type alias Model =
{ fractal : Mandelbrot.Model
, nextRow : Int
}
init : Int -> ( Model, Cmd Msg )
init size =
( { fractal = Mandelbrot.init size
, nextRow = 0
}
, calcNextRowCmd
)
calcNextRowCmd : Cmd Msg
calcNextRowCmd =
Process.sleep 0
|> Task.perform
(always CalulcateNextRow)
(always CalulcateNextRow)
-- UPDATE
type Msg
= CalulcateNextRow
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
CalulcateNextRow ->
if model.nextRow < 100 then
( { model
| fractal = Mandelbrot.computeRow model.nextRow model.fractal
, nextRow = model.nextRow + 1
}
, calcNextRowCmd
)
else
( model, Cmd.none )
-- VIEW
view : (( Int, Int ) -> msg) -> Model -> Html msg
view onClickMsg model =
Mandelbrot.view onClickMsg model.fractal