From 98511ef1165237d4a16d783ae565ca6a7b254fbf Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 28 Feb 2020 17:26:04 -0800 Subject: [PATCH] API: Canvas - drawPath (#785) * Add drawPath API * Add fillPath example * drawPath API + add to example * Update lockdir --- bench.esy.lock/index.json | 18 +++++------ .../opam/{zed.2.0.5 => zed.2.0.6}/opam | 4 +-- doc.esy.lock/index.json | 18 +++++------ .../opam/{zed.2.0.5 => zed.2.0.6}/opam | 4 +-- esy.lock/index.json | 18 +++++------ esy.lock/opam/{zed.2.0.5 => zed.2.0.6}/opam | 4 +-- examples/CanvasExample.re | 16 ++++++++++ js.esy.lock/index.json | 18 +++++------ .../opam/{zed.2.0.5 => zed.2.0.6}/opam | 4 +-- src/Draw/CanvasContext.re | 5 +++ test.esy.lock/index.json | 18 +++++------ test.esy.lock/opam/zed.2.0.5/opam | 32 ------------------- test.esy.lock/opam/zed.2.0.6/opam | 32 +++++++++++++++++++ 13 files changed, 106 insertions(+), 85 deletions(-) rename bench.esy.lock/opam/{zed.2.0.5 => zed.2.0.6}/opam (94%) rename doc.esy.lock/opam/{zed.2.0.5 => zed.2.0.6}/opam (94%) rename esy.lock/opam/{zed.2.0.5 => zed.2.0.6}/opam (94%) rename js.esy.lock/opam/{zed.2.0.5 => zed.2.0.6}/opam (94%) delete mode 100644 test.esy.lock/opam/zed.2.0.5/opam create mode 100644 test.esy.lock/opam/zed.2.0.6/opam diff --git a/bench.esy.lock/index.json b/bench.esy.lock/index.json index cb75d0572..4848e44e5 100644 --- a/bench.esy.lock/index.json +++ b/bench.esy.lock/index.json @@ -476,20 +476,20 @@ ], "devDependencies": [] }, - "@opam/zed@opam:2.0.5@80585091": { - "id": "@opam/zed@opam:2.0.5@80585091", + "@opam/zed@opam:2.0.6@d92df64a": { + "id": "@opam/zed@opam:2.0.6@d92df64a", "name": "@opam/zed", - "version": "opam:2.0.5", + "version": "opam:2.0.6", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/56/56414179d7cccba0e20005d958b5d39e#md5:56414179d7cccba0e20005d958b5d39e", - "archive:https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz#md5:56414179d7cccba0e20005d958b5d39e" + "archive:https://opam.ocaml.org/cache/md5/49/49de58f753bb4dd43ef6c2bc864ea8ff#md5:49de58f753bb4dd43ef6c2bc864ea8ff", + "archive:https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz#md5:49de58f753bb4dd43ef6c2bc864ea8ff" ], "opam": { "name": "zed", - "version": "2.0.5", - "path": "bench.esy.lock/opam/zed.2.0.5" + "version": "2.0.6", + "path": "bench.esy.lock/opam/zed.2.0.6" } }, "overrides": [], @@ -1503,7 +1503,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", @@ -1512,7 +1512,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", diff --git a/bench.esy.lock/opam/zed.2.0.5/opam b/bench.esy.lock/opam/zed.2.0.6/opam similarity index 94% rename from bench.esy.lock/opam/zed.2.0.5/opam rename to bench.esy.lock/opam/zed.2.0.6/opam index 71ef91b06..f464fabc8 100644 --- a/bench.esy.lock/opam/zed.2.0.5/opam +++ b/bench.esy.lock/opam/zed.2.0.6/opam @@ -27,6 +27,6 @@ Unicode buffers. Zed also features a regular expression search on ropes. To support efficient text edition capabilities, Zed provides macro recording and cursor management facilities.""" url { - src: "https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz" - checksum: "md5=56414179d7cccba0e20005d958b5d39e" + src: "https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz" + checksum: "md5=49de58f753bb4dd43ef6c2bc864ea8ff" } diff --git a/doc.esy.lock/index.json b/doc.esy.lock/index.json index 893d8e17c..ad4dd76a8 100644 --- a/doc.esy.lock/index.json +++ b/doc.esy.lock/index.json @@ -872,20 +872,20 @@ ], "devDependencies": [] }, - "@opam/zed@opam:2.0.5@80585091": { - "id": "@opam/zed@opam:2.0.5@80585091", + "@opam/zed@opam:2.0.6@d92df64a": { + "id": "@opam/zed@opam:2.0.6@d92df64a", "name": "@opam/zed", - "version": "opam:2.0.5", + "version": "opam:2.0.6", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/56/56414179d7cccba0e20005d958b5d39e#md5:56414179d7cccba0e20005d958b5d39e", - "archive:https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz#md5:56414179d7cccba0e20005d958b5d39e" + "archive:https://opam.ocaml.org/cache/md5/49/49de58f753bb4dd43ef6c2bc864ea8ff#md5:49de58f753bb4dd43ef6c2bc864ea8ff", + "archive:https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz#md5:49de58f753bb4dd43ef6c2bc864ea8ff" ], "opam": { "name": "zed", - "version": "2.0.5", - "path": "doc.esy.lock/opam/zed.2.0.5" + "version": "2.0.6", + "path": "doc.esy.lock/opam/zed.2.0.6" } }, "overrides": [], @@ -1932,7 +1932,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", @@ -1941,7 +1941,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", diff --git a/doc.esy.lock/opam/zed.2.0.5/opam b/doc.esy.lock/opam/zed.2.0.6/opam similarity index 94% rename from doc.esy.lock/opam/zed.2.0.5/opam rename to doc.esy.lock/opam/zed.2.0.6/opam index 71ef91b06..f464fabc8 100644 --- a/doc.esy.lock/opam/zed.2.0.5/opam +++ b/doc.esy.lock/opam/zed.2.0.6/opam @@ -27,6 +27,6 @@ Unicode buffers. Zed also features a regular expression search on ropes. To support efficient text edition capabilities, Zed provides macro recording and cursor management facilities.""" url { - src: "https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz" - checksum: "md5=56414179d7cccba0e20005d958b5d39e" + src: "https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz" + checksum: "md5=49de58f753bb4dd43ef6c2bc864ea8ff" } diff --git a/esy.lock/index.json b/esy.lock/index.json index 1ef14e883..fcdf3fd2c 100644 --- a/esy.lock/index.json +++ b/esy.lock/index.json @@ -476,20 +476,20 @@ ], "devDependencies": [] }, - "@opam/zed@opam:2.0.5@80585091": { - "id": "@opam/zed@opam:2.0.5@80585091", + "@opam/zed@opam:2.0.6@d92df64a": { + "id": "@opam/zed@opam:2.0.6@d92df64a", "name": "@opam/zed", - "version": "opam:2.0.5", + "version": "opam:2.0.6", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/56/56414179d7cccba0e20005d958b5d39e#md5:56414179d7cccba0e20005d958b5d39e", - "archive:https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz#md5:56414179d7cccba0e20005d958b5d39e" + "archive:https://opam.ocaml.org/cache/md5/49/49de58f753bb4dd43ef6c2bc864ea8ff#md5:49de58f753bb4dd43ef6c2bc864ea8ff", + "archive:https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz#md5:49de58f753bb4dd43ef6c2bc864ea8ff" ], "opam": { "name": "zed", - "version": "2.0.5", - "path": "esy.lock/opam/zed.2.0.5" + "version": "2.0.6", + "path": "esy.lock/opam/zed.2.0.6" } }, "overrides": [], @@ -1503,7 +1503,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", @@ -1512,7 +1512,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", diff --git a/esy.lock/opam/zed.2.0.5/opam b/esy.lock/opam/zed.2.0.6/opam similarity index 94% rename from esy.lock/opam/zed.2.0.5/opam rename to esy.lock/opam/zed.2.0.6/opam index 71ef91b06..f464fabc8 100644 --- a/esy.lock/opam/zed.2.0.5/opam +++ b/esy.lock/opam/zed.2.0.6/opam @@ -27,6 +27,6 @@ Unicode buffers. Zed also features a regular expression search on ropes. To support efficient text edition capabilities, Zed provides macro recording and cursor management facilities.""" url { - src: "https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz" - checksum: "md5=56414179d7cccba0e20005d958b5d39e" + src: "https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz" + checksum: "md5=49de58f753bb4dd43ef6c2bc864ea8ff" } diff --git a/examples/CanvasExample.re b/examples/CanvasExample.re index 8fc674332..2d1f8cdf0 100644 --- a/examples/CanvasExample.re +++ b/examples/CanvasExample.re @@ -33,6 +33,22 @@ module Sample = { let rect = Skia.Rect.makeLtrb(1.0, 1.0, 101., 201.); CanvasContext.drawRect(~rect, ~paint, canvasContext); + let stroke = Skia.Paint.make(); + Skia.Paint.setColor( + stroke, + Skia.Color.makeArgb(0xFFl, 0xFFl, 0x00l, 0x00l), + ); + Skia.Paint.setAntiAlias(stroke, true); + Skia.Paint.setStyle(stroke, Stroke); + Skia.Paint.setStrokeWidth(stroke, 5.); + + let path = Skia.Path.make(); + Skia.Path.moveTo(path, 50., 50.); + Skia.Path.lineTo(path, 590., 50.); + Skia.Path.cubicTo(path, -490., 50., 1130., 430., 50., 430.); + Skia.Path.lineTo(path, 590., 430.); + CanvasContext.drawPath(~path, ~paint=stroke, canvasContext); + switch (Revery_Font.load("Roboto-Regular.ttf")) { | Error(_) => () | Ok(font) => diff --git a/js.esy.lock/index.json b/js.esy.lock/index.json index 0627fa7df..72cb344fe 100644 --- a/js.esy.lock/index.json +++ b/js.esy.lock/index.json @@ -872,20 +872,20 @@ ], "devDependencies": [] }, - "@opam/zed@opam:2.0.5@80585091": { - "id": "@opam/zed@opam:2.0.5@80585091", + "@opam/zed@opam:2.0.6@d92df64a": { + "id": "@opam/zed@opam:2.0.6@d92df64a", "name": "@opam/zed", - "version": "opam:2.0.5", + "version": "opam:2.0.6", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/56/56414179d7cccba0e20005d958b5d39e#md5:56414179d7cccba0e20005d958b5d39e", - "archive:https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz#md5:56414179d7cccba0e20005d958b5d39e" + "archive:https://opam.ocaml.org/cache/md5/49/49de58f753bb4dd43ef6c2bc864ea8ff#md5:49de58f753bb4dd43ef6c2bc864ea8ff", + "archive:https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz#md5:49de58f753bb4dd43ef6c2bc864ea8ff" ], "opam": { "name": "zed", - "version": "2.0.5", - "path": "js.esy.lock/opam/zed.2.0.5" + "version": "2.0.6", + "path": "js.esy.lock/opam/zed.2.0.6" } }, "overrides": [], @@ -1899,7 +1899,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", @@ -1908,7 +1908,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", diff --git a/js.esy.lock/opam/zed.2.0.5/opam b/js.esy.lock/opam/zed.2.0.6/opam similarity index 94% rename from js.esy.lock/opam/zed.2.0.5/opam rename to js.esy.lock/opam/zed.2.0.6/opam index 71ef91b06..f464fabc8 100644 --- a/js.esy.lock/opam/zed.2.0.5/opam +++ b/js.esy.lock/opam/zed.2.0.6/opam @@ -27,6 +27,6 @@ Unicode buffers. Zed also features a regular expression search on ropes. To support efficient text edition capabilities, Zed provides macro recording and cursor management facilities.""" url { - src: "https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz" - checksum: "md5=56414179d7cccba0e20005d958b5d39e" + src: "https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz" + checksum: "md5=49de58f753bb4dd43ef6c2bc864ea8ff" } diff --git a/src/Draw/CanvasContext.re b/src/Draw/CanvasContext.re index b69acdaaa..0f27b7a77 100644 --- a/src/Draw/CanvasContext.re +++ b/src/Draw/CanvasContext.re @@ -138,9 +138,14 @@ let clear = (~color: Skia.Color.t, v: t) => { Canvas.clear(v.canvas, color); }; +let drawPath = (~path: Skia.Path.t, ~paint: Paint.t, canvasContext: t) => { + Canvas.drawPath(canvasContext.canvas, path, paint); +}; + let drawRect = (~rect: Skia.Rect.t, ~paint: Paint.t, v: t) => { Canvas.drawRect(v.canvas, rect, paint); }; + let drawRectLtwh = ( ~left: float, diff --git a/test.esy.lock/index.json b/test.esy.lock/index.json index c64c64ba6..921c795d6 100644 --- a/test.esy.lock/index.json +++ b/test.esy.lock/index.json @@ -476,20 +476,20 @@ ], "devDependencies": [] }, - "@opam/zed@opam:2.0.5@80585091": { - "id": "@opam/zed@opam:2.0.5@80585091", + "@opam/zed@opam:2.0.6@d92df64a": { + "id": "@opam/zed@opam:2.0.6@d92df64a", "name": "@opam/zed", - "version": "opam:2.0.5", + "version": "opam:2.0.6", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/56/56414179d7cccba0e20005d958b5d39e#md5:56414179d7cccba0e20005d958b5d39e", - "archive:https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz#md5:56414179d7cccba0e20005d958b5d39e" + "archive:https://opam.ocaml.org/cache/md5/49/49de58f753bb4dd43ef6c2bc864ea8ff#md5:49de58f753bb4dd43ef6c2bc864ea8ff", + "archive:https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz#md5:49de58f753bb4dd43ef6c2bc864ea8ff" ], "opam": { "name": "zed", - "version": "2.0.5", - "path": "test.esy.lock/opam/zed.2.0.5" + "version": "2.0.6", + "path": "test.esy.lock/opam/zed.2.0.6" } }, "overrides": [], @@ -1503,7 +1503,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", @@ -1512,7 +1512,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", + "ocaml@4.8.1000@d41d8cd9", "@opam/zed@opam:2.0.6@d92df64a", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.5.0@677655b4", diff --git a/test.esy.lock/opam/zed.2.0.5/opam b/test.esy.lock/opam/zed.2.0.5/opam deleted file mode 100644 index 71ef91b06..000000000 --- a/test.esy.lock/opam/zed.2.0.5/opam +++ /dev/null @@ -1,32 +0,0 @@ -opam-version: "2.0" -maintainer: "opam-devel@lists.ocaml.org" -authors: ["Jérémie Dimino"] -homepage: "https://github.com/ocaml-community/zed" -bug-reports: "https://github.com/ocaml-community/zed/issues" -dev-repo: "git://github.com/ocaml-community/zed.git" -license: "BSD-3-Clause" -depends: [ - "ocaml" {>= "4.02.3"} - "dune" {>= "1.1.0"} - "base-bytes" - "camomile" {>= "1.0.1"} - "react" - "charInfo_width" {>= "1.1.0" & < "2.0~"} -] -build: [ - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] -synopsis: "Abstract engine for text edition in OCaml" -description: """ -Zed is an abstract engine for text edition. It can be used to write text -editors, edition widgets, readlines, ... Zed uses Camomile to fully support the -Unicode specification, and implements an UTF-8 encoded string type with -validation, and a rope datastructure to achieve efficient operations on large -Unicode buffers. Zed also features a regular expression search on ropes. To -support efficient text edition capabilities, Zed provides macro recording and -cursor management facilities.""" -url { - src: "https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz" - checksum: "md5=56414179d7cccba0e20005d958b5d39e" -} diff --git a/test.esy.lock/opam/zed.2.0.6/opam b/test.esy.lock/opam/zed.2.0.6/opam new file mode 100644 index 000000000..f464fabc8 --- /dev/null +++ b/test.esy.lock/opam/zed.2.0.6/opam @@ -0,0 +1,32 @@ +opam-version: "2.0" +maintainer: "opam-devel@lists.ocaml.org" +authors: ["Jérémie Dimino"] +homepage: "https://github.com/ocaml-community/zed" +bug-reports: "https://github.com/ocaml-community/zed/issues" +dev-repo: "git://github.com/ocaml-community/zed.git" +license: "BSD-3-Clause" +depends: [ + "ocaml" {>= "4.02.3"} + "dune" {>= "1.1.0"} + "base-bytes" + "camomile" {>= "1.0.1"} + "react" + "charInfo_width" {>= "1.1.0" & < "2.0~"} +] +build: [ + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Abstract engine for text edition in OCaml" +description: """ +Zed is an abstract engine for text edition. It can be used to write text +editors, edition widgets, readlines, ... Zed uses Camomile to fully support the +Unicode specification, and implements an UTF-8 encoded string type with +validation, and a rope datastructure to achieve efficient operations on large +Unicode buffers. Zed also features a regular expression search on ropes. To +support efficient text edition capabilities, Zed provides macro recording and +cursor management facilities.""" +url { + src: "https://github.com/ocaml-community/zed/releases/download/2.0.6/zed-2.0.6.tbz" + checksum: "md5=49de58f753bb4dd43ef6c2bc864ea8ff" +}