Created
February 12, 2019 20:08
Revisions
-
Shelomanov Dmitry created this gist
Feb 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ open Webapi.Dom; open Webapi.Canvas.CanvasElement; open Point; open App; open Draw; let worldMaxSize = 400.0; let tick = (world) => { world |> viewPopulation |> Js_array.forEach(shape => switch (shape) { | Circle(circle) => circle.point = add(vector2(0.1, 0.1), circle.point) } ); }; let main = () => { let canvas = Belt.Option.(document |> Document.getElementById("app") |> getExn); let ctx = getContext2d(canvas); let world = create( ~boundaries={width: 400.0, height: 400.0}, ~population=[| makeCircle(~r=20.0, ~point=vector2(10.0, 10.0), ()), makeCircle(~r=5.0, ~point=vector2(100.0, 100.0), ()), |], ctx, ); render(world, tick); }; main();