I have a question about Elm canvas. Is there a way to prevent the canvas to be erased/reinserted in the DOM on each frame?
I am trying to dynamically generate an image by changing a particle system (Model
) and then drawing it. The pseudocode looks like bellow.
My only "solution" is not to change the particles and instead to keep adding but I am not happy with the approach.
type alias Particle = { ... }
type alias Model = List Particle
update msg model =
List.map updateParticle model
view model =
collage 900 900
((rect 900 900 |> filled bg) :: (List.map drawParticle model))
-- later edit
drawParticle p =
segment p.start p.end
|> traced defaultLine
[EDIT]
In order to make it clear what the DOM contains, I added drawParticle
function to the code above.