Skip to content

Commit

Permalink
API: Canvas - drawPath (#785)
Browse files Browse the repository at this point in the history
* Add drawPath API

* Add fillPath example

* drawPath API + add to example

* Update lockdir
  • Loading branch information
bryphe authored Feb 29, 2020
1 parent 5df4903 commit 98511ef
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 85 deletions.
18 changes: 9 additions & 9 deletions bench.esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions doc.esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions esy.lock/opam/zed.2.0.5/opam → esy.lock/opam/zed.2.0.6/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions examples/CanvasExample.re
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
18 changes: 9 additions & 9 deletions js.esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Draw/CanvasContext.re
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions test.esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions test.esy.lock/opam/zed.2.0.5/opam

This file was deleted.

32 changes: 32 additions & 0 deletions test.esy.lock/opam/zed.2.0.6/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98511ef

Please sign in to comment.