aboutsummaryrefslogtreecommitdiff
path: root/script.it/layer/canvaPrinter.ml
blob: 23cf842214df2d0f25226dc5d6385a3c26f352f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module Path = Brr_canvas.C2d.Path
module V2 = Gg.V2

type t = Path.t

let create
  : unit -> t
  = Path.create

(* Start a new path. *)
let move_to
  : Gg.v2 -> t -> t
  = fun point path ->
    let x, y = V2.to_tuple point in
    Path.move_to ~x ~y path;
    path

let line_to
  : Gg.v2 -> t -> 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 -> t -> 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
  : t -> t
  = fun path ->
    Path.close path;
    path