aboutsummaryrefslogtreecommitdiff
path: root/layer
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2020-12-20 11:57:14 +0100
committerSébastien Dailly <sebastien@chimrod.com>2020-12-20 11:57:14 +0100
commita86ede2f3d29d6de6ef7c1eab577f00d4c583660 (patch)
tree7cd3a5185d8ebf995f75238fce6904b71c62596e /layer
parent986a36b3728eba40789d6063997dafda67b519ec (diff)
Update
Diffstat (limited to 'layer')
-rwxr-xr-xlayer/canvaPrinter.ml42
-rwxr-xr-xlayer/canvaPrinter.mli2
-rwxr-xr-xlayer/dune8
-rwxr-xr-xlayer/repr.ml19
4 files changed, 71 insertions, 0 deletions
diff --git a/layer/canvaPrinter.ml b/layer/canvaPrinter.ml
new file mode 100755
index 0000000..e696d10
--- /dev/null
+++ b/layer/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
diff --git a/layer/canvaPrinter.mli b/layer/canvaPrinter.mli
new file mode 100755
index 0000000..e273054
--- /dev/null
+++ b/layer/canvaPrinter.mli
@@ -0,0 +1,2 @@
+include Repr.PRINTER
+ with type 'a t = Brr_canvas.C2d.Path.t
diff --git a/layer/dune b/layer/dune
new file mode 100755
index 0000000..f0b1b13
--- /dev/null
+++ b/layer/dune
@@ -0,0 +1,8 @@
+(library
+ (name layer)
+ (libraries
+ gg
+ brr
+ shapes
+ )
+ )
diff --git a/layer/repr.ml b/layer/repr.ml
new file mode 100755
index 0000000..b91442b
--- /dev/null
+++ b/layer/repr.ml
@@ -0,0 +1,19 @@
+module type PRINTER = sig
+
+ type 'a t
+
+ val create: unit -> 'a t
+
+ (* Start a new path. *)
+ val move_to: Gg.v2 -> 'a t -> 'a t
+
+ val line_to: Gg.v2 -> 'a t -> 'a t
+
+ (** [quadratic_to ctrl0 ctrl1 p1] ctreate a quadratic curve from the current
+ point to [p1], with control points [ctrl0] and [ctrl1] *)
+ val quadratic_to: Gg.v2 -> Gg.v2 -> Gg.v2 -> 'a t -> 'a t
+
+ (** Request for the path to be closed *)
+ val close: 'a t -> 'a t
+
+end