0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00
This commit is contained in:
Alejandro Alonso 2023-12-22 12:18:59 +01:00
parent fa84b1e67d
commit 00ce454ba6

View file

@ -110,18 +110,32 @@ class CanvasKit {
// Drawing fills
if (shape.fills) {
for (const fill of shape.fills.reverse()) {
paint.setStyle(this.CanvasKit.PaintStyle.Fill);
const color = this.CanvasKit.parseColorString(fill["fill-color"]);
const opacity = fill["fill-opacity"];
console.log("fill color", fill["fill-color"], 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),
rx,
ry,
);
canvas.drawRRect(rr, paint);
if (fill["fill-color"]) {
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),
rx,
ry,
);
canvas.drawRRect(rr, paint);
}
else if (fill["fill-image"]) {
let realPromise = fetch("/assets/by-file-media-id/" + fill["fill-image"].id)
.then((response) => response.blob())
.then((blob) => createImageBitmap(blob))
.then((bitmap) => this.CanvasKit.MakeImageFromCanvasImageSource(bitmap))
.then((img) => {
const self = this;
const s = this.CanvasKit.MakeCanvasSurface(self.canvasId);
s.drawOnce((c) => {
c.drawImage(img, shape.x, shape.y, null)
});
});
}
}
}
// Drawing strokes