rescript-webapi
rescript-webapi copied to clipboard
Path 2D module
As result of https://github.com/TheSpyder/rescript-webapi/issues/132
Path2d module added with following js bindings, see on MDN
- addPath
- arc
- arcTo
- bezierCurveTo
- closePath
- ellipse
- lineTo
- moveTo
- quadraticCurveTo
- rect
- roundRect
Syntax
open Webapi.Canvas
let path1 = Path2d.make()
let path2 = Path2d.make(~d="M10 10 h 80 v 80 h -80 Z", ())
path1->Path2d.addPath(path2)
path1->Path2d.arc(~x=1.,~y =2.,~r=3.,~a1 = 4., ~a2 =5.,())
Changelog
- added Path2d module
- added Canvas2d ellipse roundRect bindings
Breaking
- Updated common Path2d/Canvas2d params names to 1~3 characters matching mdn docs
+ ctx->quadraticCurveTo(~cp1x=1., ~cp1y=1., ~x=1., ~y=1.)
- ctx->quadraticCurveTo(~cpx=1., ~cpy=1., ~x=1., ~y=1.)
+ ctx->arc(~x=1., ~y=1., ~r=4., ~startAngle=1., ~endAngle=3., ~anticw=true)
- ctx->arc(~x=1., ~y=1., ~r=4., ~startAngle=1., ~endAngle=3., ~counterClockWise=true, ())
- Added Path2d.make, Dropped Canvas2d.strokePath2D
+ let path = Path2d.make(~d="M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223")
- let path: path2d = newPath2D("M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223")
- Canvas2d functions taking Path2d renamed
++ ctx->strokePath2D(path)
++ ctx->fillPath2D(path)
-- ctx->strokePath2d(path1)
-- ctx->fillPath2d(path2)
TODO
- [x] add Path2d module
- [x] export Path2d from
src/Webapi/Webapi__Canvas.res
- [x] remove
Canvas2d.newPath2D()
in favor ofPath2d.make(~d=?)
- [x] add missing Canvas2d methods
- [x] Updated canvas2s test
- [x] extract common methods between Path2d and Context2D (Functor with parametric
t
) - [x] list breaking changes