mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -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
|
// 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue