mirror of
https://github.com/penpot/penpot.git
synced 2026-04-29 05:08:08 +00:00
WIP
This commit is contained in:
parent
69582add4b
commit
721d9ee399
@ -19,15 +19,15 @@
|
||||
|
||||
(mf/with-effect [objects]
|
||||
(when @canvas-kit
|
||||
(do
|
||||
(doseq [[_ object] objects]
|
||||
(.paintRect ^js @canvas-kit (clj->js object))))))
|
||||
(doseq [[_ object] objects]
|
||||
(.paintRect ^js @canvas-kit (clj->js object)))))
|
||||
|
||||
(mf/with-effect [canvas-ref]
|
||||
(let [canvas (mf/ref-val canvas-ref)]
|
||||
(when (some? canvas)
|
||||
(set! (.-width canvas) (.-clientWidth canvas))
|
||||
(set! (.-height canvas) (.-clientHeight canvas))
|
||||
(println "init vbox" vbox)
|
||||
(-> (.initialize impl/CanvasKit "skia-canvas" vbox)
|
||||
(.then (fn [k]
|
||||
(reset! canvas-kit k)))))))
|
||||
|
||||
@ -19,28 +19,27 @@ class CanvasKit {
|
||||
paintRect(shape) {
|
||||
const surface = this.CanvasKit.MakeCanvasSurface(this.canvasId)
|
||||
|
||||
// Drawing fills
|
||||
if (shape.fills) {
|
||||
for (const fill of shape.fills) {
|
||||
const paint = new this.CanvasKit.Paint();
|
||||
paint.setStyle(this.CanvasKit.PaintStyle.Fill);
|
||||
const color = this.CanvasKit.parseColorString(fill["fill-color"]);
|
||||
const opacity = fill["fill-opacity"]
|
||||
color[3] = opacity
|
||||
paint.setColor(color);
|
||||
const rr = this.CanvasKit.RRectXY(this.CanvasKit.LTRBRect(shape.x, shape.y, shape.x + shape.width, shape.y + shape.height), 0, 0);
|
||||
const self = this;
|
||||
|
||||
function draw(canvas) {
|
||||
canvas.translate(- self.vbox.x, - self.vbox.y);
|
||||
const self = this;
|
||||
function draw(canvas) {
|
||||
canvas.translate(- self.vbox.x, - self.vbox.y);
|
||||
const paint = new self.CanvasKit.Paint();
|
||||
// Drawing fills
|
||||
if (shape.fills) {
|
||||
for (const fill of shape.fills.reverse()) {
|
||||
paint.setStyle(self.CanvasKit.PaintStyle.Fill);
|
||||
const color = self.CanvasKit.parseColorString(fill["fill-color"]);
|
||||
const opacity = fill["fill-opacity"]
|
||||
color[3] = opacity
|
||||
paint.setColor(color);
|
||||
const rr = self.CanvasKit.RRectXY(self.CanvasKit.LTRBRect(shape.x, shape.y, shape.x + shape.width, shape.y + shape.height), 0, 0);
|
||||
canvas.drawRRect(rr, paint);
|
||||
paint.delete();
|
||||
}
|
||||
|
||||
surface.drawOnce(draw);
|
||||
}
|
||||
paint.delete();
|
||||
}
|
||||
|
||||
|
||||
surface.drawOnce(draw);
|
||||
|
||||
// // Drawing another border
|
||||
// const paint2 = new this.CanvasKit.Paint();
|
||||
// paint2.setColor(this.CanvasKit.Color4f(0.9, 0, 1.0, 1.0));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user