Skip to content
Browse files

filled_poly

  • Loading branch information...
1 parent 69bc240 commit bec97a6b2540faae25f28d81c002ef0c283325dd Jake Donham committed
Showing with 10 additions and 0 deletions.
  1. +8 −0 src/froc-dom/froc_dom_anim.ml
  2. +2 −0 src/froc-dom/froc_dom_anim.mli
View
8 src/froc-dom/froc_dom_anim.ml
@@ -34,6 +34,14 @@ let disk (cx, cy) radius color : shape =
ctx#arc cx cy radius 0. (2. *. Javascript.Math.pi) true;
ctx#fill)
+let filled_poly points color : shape =
+ (fun ctx ->
+ ctx#_set_fillStyle color;
+ ctx#beginPath;
+ List.iter (fun (x, y) -> ctx#lineTo x y) points;
+ ctx#closePath;
+ ctx#fill)
+
let draw canvas instrs =
let ctx = canvas#getContext "2d" in
ctx#clearRect 0. 0. (float_of_int canvas#_get_width) (float_of_int canvas#_get_height);
View
2 src/froc-dom/froc_dom_anim.mli
@@ -26,4 +26,6 @@ val color : ?a:int -> int -> int -> int -> color
val disk : point -> float -> color -> shape
+val filled_poly : point list -> color -> shape
+
val attach : Dom.canvas -> shape list Froc.behavior -> unit

0 comments on commit bec97a6

Please sign in to comment.
Something went wrong with that request. Please try again.