0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-01 11:59:17 -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 // Drawing fills
if (shape.fills) { if (shape.fills) {
for (const fill of shape.fills.reverse()) { for (const fill of shape.fills.reverse()) {
paint.setStyle(this.CanvasKit.PaintStyle.Fill); if (fill["fill-color"]) {
const color = this.CanvasKit.parseColorString(fill["fill-color"]); paint.setStyle(this.CanvasKit.PaintStyle.Fill);
const opacity = fill["fill-opacity"]; const color = this.CanvasKit.parseColorString(fill["fill-color"]);
console.log("fill color", fill["fill-color"], fill["fill-opacity"]); const opacity = fill["fill-opacity"];
color[3] = opacity; color[3] = opacity;
paint.setColor(color); paint.setColor(color);
const rr = this.CanvasKit.RRectXY( const rr = this.CanvasKit.RRectXY(
this.CanvasKit.LTRBRect(shape.x, shape.y, shape.x + shape.width, shape.y + shape.height), this.CanvasKit.LTRBRect(shape.x, shape.y, shape.x + shape.width, shape.y + shape.height),
rx, rx,
ry, ry,
); );
canvas.drawRRect(rr, paint); 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 // Drawing strokes