mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
WIP
This commit is contained in:
parent
fa84b1e67d
commit
00ce454ba6
1 changed files with 26 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue