diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2020-12-19 19:59:17 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2020-12-19 19:59:17 +0100 |
commit | 0faaa5fda396f0eca6bebf69f3624a344278fa6e (patch) | |
tree | cbca5d2f306506c0896f83b8bdd45b777c78aa35 /path/canvaPrinter.ml | |
parent | e5c2a971644746818f8764481c60c4c5cf1a80c4 (diff) |
First commit
Diffstat (limited to 'path/canvaPrinter.ml')
-rwxr-xr-x | path/canvaPrinter.ml | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/path/canvaPrinter.ml b/path/canvaPrinter.ml new file mode 100755 index 0000000..e696d10 --- /dev/null +++ b/path/canvaPrinter.ml @@ -0,0 +1,42 @@ +module Path = Brr_canvas.C2d.Path +module V2 = Gg.V2 + +type 'a t = Path.t + +let create + : unit -> 'a t + = Path.create + +(* Start a new path. *) +let move_to + : Gg.v2 -> 'a t -> 'a t + = fun point path -> + let x, y = V2.to_tuple point in + Path.move_to ~x ~y path; + path + +let line_to + : Gg.v2 -> 'a t -> 'a t + = fun point path -> + let x, y = V2.to_tuple point in + Path.line_to ~x ~y path; + path + +let quadratic_to + : Gg.v2 -> Gg.v2 -> Gg.v2 -> 'a t -> 'a t + = fun ctrl0 ctrl1 p1 path -> + let cx, cy = V2.to_tuple ctrl0 + and cx', cy' = V2.to_tuple ctrl1 + and x, y = V2.to_tuple p1 in + Path.ccurve_to + ~cx ~cy + ~cx' ~cy' + ~x ~y + path; + path + +let close + : 'a t -> 'a t + = fun path -> + Path.close path; + path |