-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlifecycle.puml
123 lines (110 loc) · 4.23 KB
/
lifecycle.puml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@startuml
title Art player initialization
autonumber 1.1
skinparam pageMargin 10
participant Browser
participant Artwork
participant API
participant PlatformAdapter
participant TimeProvider
activate Browser
== Startup ==
Browser -> Browser : Load HTML w/ GenArt API script
activate API
API -> API : Initialize
Browser -> PlatformAdapter : Load platform adapter
activate PlatformAdapter
PlatformAdapter -> PlatformAdapter : Initialize (optional)
PlatformAdapter -> PlatformAdapter : Initialize PRNG
note left : Seeding MUST happen\nbefore artwork starts
PlatformAdapter -> PlatformAdapter : Set execution mode
note left : Play / Preview / Edit
PlatformAdapter -> API : Register
note right : `$genart.setAdapter()`
deactivate PlatformAdapter
deactivate API
Browser --> TimeProvider : Load custom timing provider
note right : optional, API uses `timingProviderRAF()`\nby default
activate TimeProvider
TimeProvider --> TimeProvider : Initialize (optional)
TimeProvider -> API : Register
note right : `$genart.setTime()`
deactivate TimeProvider
Browser -> Artwork : Load artwork script
activate Artwork
Artwork -> API : Wait for adapter registration
note left : `await $genart.waitForAdapter()`
API --> Artwork : Return when adapter available...
Artwork -> API : Declare & register param specs (async)
activate API
note left
`$genart.setParams({...})`
end note
API -> PlatformAdapter : Augment param specs (optional)
note right : `adapter.augmentParams()`\nAllow adapter to inject additional platform specific params
PlatformAdapter --> API : Return updated specs
API -> API : Validate params specs
note right : Ensure valid param types
API -> API : Add missing default values
note right : Randomize missing defaults
API -> API : Set param states
note right : Depending on provided defaults
API -> PlatformAdapter : Pre-initialize params (async)
note right : `adapter.initParams()`\n(e.g. load params via network request)
PlatformAdapter --> API : Return when ready
API -> PlatformAdapter : Update param values
activate PlatformAdapter
PlatformAdapter -> PlatformAdapter : Parse param values/overrides
note right : `adapter.updateParam()`\nsource param values via\nplatform-specific means
PlatformAdapter --> API : Customized param value(s)
deactivate PlatformAdapter
API -> API : Update param states
note right : Set to `custom` (only those which changed)
API -> API : Validate & apply param overrides
API -->> API : Emit `genart:setparams` message
note right : Sent to current & parent window
API --> Artwork : Typesafe param getter function
note left : Artwork uses this function\nto obtain param values
deactivate API
Artwork -> API : Request screen config
API -> PlatformAdapter : Request screen config
note right : optionally define resolution
PlatformAdapter --> API : Config
API --> Artwork : Config
Artwork -> Artwork : Initialize
Artwork -> API : Get param value
note left : Optionally time-based or randomized
activate API
API -> API : Delegate to param type impl
note right : Uses `ParamImpl.read()` if type defines it
API --> Artwork : Param value
deactivate API
== Animation start ==
Artwork -> API : Register update/draw function
deactivate Artwork
API -> API : Transition state to `ready`
API --> API : Emit `genart:statechange` message
activate PlatformAdapter
PlatformAdapter -> PlatformAdapter : Process `ready` state change
PlatformAdapter -> API : Start anim loop
note right : Platform decides auto-start behavior
deactivate PlatformAdapter
activate API
API -> TimeProvider : Start (reset timestamp)
loop Animation loop
API -> TimeProvider : Queue next frame update
note right : Default: `requestAnimationFrame()`
TimeProvider --> API : Trigger update with current time & frame
API -> Artwork : Call update w/ timestamp
activate Artwork
Artwork -> Artwork : Generate next frame
Artwork -> API : Trigger screen capture (once, after X seconds)
note left: `$genart.capture(canvas)`
deactivate Artwork
API -> PlatformAdapter : Handle screen capture
note right : Optional, platform specific
API --> API : Emit `genart:capture` message
end
deactivate API
deactivate Browser
@enduml