Skip to content

Commit 95f4326

Browse files
author
saŭlo
committed
Path2d Impl module
1 parent da18ede commit 95f4326

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

src/Webapi/Canvas/Webapi__Canvas__Canvas2d.res

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,10 @@ external strokeText: (t, string, ~x: float, ~y: float, ~maxWidth: float=?, @igno
239239
@send external strokeRect: (t, ~x: float, ~y: float, ~w: float, ~h: float) => unit = "strokeRect"
240240
@send external clearRect: (t, ~x: float, ~y: float, ~w: float, ~h: float) => unit = "clearRect"
241241

242-
module T = {
243-
type t = t
244-
}
245-
246242
// CanvasPathCommons
247-
include Webapi__Canvas__Path_Common.Make(T)
243+
include Webapi__Canvas__Path_Common.Impl({
244+
type t = t
245+
})
248246

249247
/* Pixel maniplation */
250248
@send

src/Webapi/Canvas/Webapi__Canvas__Path2d.res

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ external make: (~d: string=?, unit) => t = "Path2D"
1212
@send
1313
external addPath: (t, t) => unit = "addPath"
1414

15-
module T = {
16-
type t = t
17-
}
18-
1915
// CanvasPathCommons
20-
include Webapi__Canvas__Path_Common.Make(T)
16+
include Webapi__Canvas__Path_Common.Impl( {
17+
type t = t
18+
})
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
module type ModuleWithT = {
2-
type t
3-
}
4-
51
/**
62
* Named parameters have 1~3 of lenght, should resemble MDN/typescript docs/types.
73
* This module exposes the typescript CanvasPath interface
84
* https://github.com/microsoft/TypeScript/blob/46410044add2e9f53cea58e445de18dcda53443f/src/lib/dom.generated.d.ts#L5455
95
*/
10-
module Make = (M: ModuleWithT) => {
6+
module Impl = (
7+
T: {
8+
type t
9+
},
10+
) => {
1111
// type t = M.t
1212
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arc */
1313
@send
1414
external arc: (
15-
M.t,
15+
T.t,
1616
~x: float,
1717
~y: float,
1818
~r: float,
@@ -24,12 +24,12 @@ module Make = (M: ModuleWithT) => {
2424

2525
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arcTo */
2626
@send
27-
external arcTo: (M.t, ~x1: float, ~y1: float, ~x2: float, ~y2: float, ~r: float) => unit = "arcTo"
27+
external arcTo: (T.t, ~x1: float, ~y1: float, ~x2: float, ~y2: float, ~r: float) => unit = "arcTo"
2828

2929
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo */
3030
@send
3131
external bezierCurveTo: (
32-
M.t,
32+
T.t,
3333
~cp1x: float,
3434
~cp1y: float,
3535
~cp2x: float,
@@ -40,12 +40,12 @@ module Make = (M: ModuleWithT) => {
4040

4141
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/closePath*/
4242
@send
43-
external closePath: M.t => unit = "closePath"
43+
external closePath: T.t => unit = "closePath"
4444

4545
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse */
4646
@send
4747
external ellipse: (
48-
M.t,
48+
T.t,
4949
~x: float,
5050
~y: float,
5151
~rx: float,
@@ -59,23 +59,23 @@ module Make = (M: ModuleWithT) => {
5959

6060
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineTo */
6161
@send
62-
external lineTo: (M.t, ~x: float, ~y: float) => unit = "lineTo"
62+
external lineTo: (T.t, ~x: float, ~y: float) => unit = "lineTo"
6363

6464
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/moveTo */
6565
@send
66-
external moveTo: (M.t, ~x: float, ~y: float) => unit = "moveTo"
66+
external moveTo: (T.t, ~x: float, ~y: float) => unit = "moveTo"
6767

6868
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/quadraticCurveTo */
6969
@send
70-
external quadraticCurveTo: (M.t, ~cpx: float, ~cpy: float, ~x: float, ~y: float) => unit =
70+
external quadraticCurveTo: (T.t, ~cpx: float, ~cpy: float, ~x: float, ~y: float) => unit =
7171
"quadraticCurveTo"
7272

7373
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rect */
7474
@send
75-
external rect: (M.t, ~x: float, ~y: float, ~w: float, ~h: float) => unit = "rect"
75+
external rect: (T.t, ~x: float, ~y: float, ~w: float, ~h: float) => unit = "rect"
7676

7777
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect */
7878
@send
79-
external roundRect: (M.t, ~x: float, ~y: float, ~w: float, ~h: float, ~r: float) => unit =
79+
external roundRect: (T.t, ~x: float, ~y: float, ~w: float, ~h: float, ~r: float) => unit =
8080
"roundRect"
8181
}

0 commit comments

Comments
 (0)