From 25afb0bde9b8a2c064135a534231c232a461b341 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 16 Feb 2020 22:45:07 +0100 Subject: Set up a first version of tabata timer --- src/arc.ml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/arc.ml (limited to 'src/arc.ml') diff --git a/src/arc.ml b/src/arc.ml new file mode 100644 index 0000000..7a3195d --- /dev/null +++ b/src/arc.ml @@ -0,0 +1,23 @@ +let polarToCartesian centerX centerY radius angleInDegrees = + let angleInRadians = (angleInDegrees -. 90.0) *. Js.Math._PI /. 180.0 in + ( centerX +. (radius *. Js.Math.cos angleInRadians), + centerY +. (radius *. Js.Math.sin angleInRadians) ) + +let describe x y radius startAngle endAngle = + let startX, startY = polarToCartesian x y radius endAngle in + let endX, endY = polarToCartesian x y radius startAngle in + let largeArcFlag = if endAngle -. startAngle <= 180.0 then "0" else "1" in + [| + "M"; + Js.Float.toString startX; + Js.Float.toString startY; + "A"; + Js.Float.toString radius; + Js.Float.toString radius; + "0"; + largeArcFlag; + "0"; + Js.Float.toString endX; + Js.Float.toString endY; + |] + |> Js.Array.joinWith " " -- cgit v1.2.3