mirror of
https://github.com/penpot/penpot.git
synced 2026-08-06 04:48:39 +00:00
WIP
This commit is contained in:
parent
5b8c8e93b2
commit
4cf1406cae
@ -83,10 +83,28 @@ class CanvasKit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawRect(canvas, shape) {
|
drawRect(canvas, shape) {
|
||||||
|
let blur = null
|
||||||
const paint = new this.CanvasKit.Paint();
|
const paint = new this.CanvasKit.Paint();
|
||||||
paint.setBlendMode(this.getBlendModeFromObject(shape));
|
paint.setBlendMode(this.getBlendModeFromObject(shape));
|
||||||
const rx = shape['rx'] || shape['r1'] || 0;
|
const rx = shape['rx'] || shape['r1'] || 0;
|
||||||
const ry = shape['ry'] || shape['r1'] || 0;
|
const ry = shape['ry'] || shape['r1'] || 0;
|
||||||
|
if (shape.blur) {
|
||||||
|
const paintBlur = new this.CanvasKit.Paint();
|
||||||
|
}
|
||||||
|
if (shape.shadow && (shape.shadow.length > 0)) {
|
||||||
|
const paintShadow = new this.CanvasKit.Paint();
|
||||||
|
const [first] = shape.shadow
|
||||||
|
const color = this.CanvasKit.parseColorString(first.color.color)
|
||||||
|
color[3] = first.color.opacity
|
||||||
|
const shadow = this.CanvasKit.ImageFilter.MakeDropShadowOnly(first['offset-x'], first['offset-y'], first.blur, first.blur, color, blur);
|
||||||
|
const shadowRect = this.CanvasKit.RRectXY(
|
||||||
|
this.CanvasKit.LTRBRect(shape.x, shape.y, shape.x + shape.width, shape.y + shape.height),
|
||||||
|
rx,
|
||||||
|
ry)
|
||||||
|
paintShadow.setImageFilter(shadow)
|
||||||
|
canvas.drawRRect(shadowRect, paintShadow)
|
||||||
|
paintShadow.delete()
|
||||||
|
}
|
||||||
// Drawing fills
|
// Drawing fills
|
||||||
if (shape.fills) {
|
if (shape.fills) {
|
||||||
for (const fill of shape.fills.reverse()) {
|
for (const fill of shape.fills.reverse()) {
|
||||||
@ -123,10 +141,8 @@ class CanvasKit {
|
|||||||
canvas.drawRRect(rr, paint);
|
canvas.drawRRect(rr, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let blur = null
|
|
||||||
if (shape.blur) {
|
if (shape.blur) {
|
||||||
const paintBlur = new this.CanvasKit.Paint();
|
const paintBlur = new this.CanvasKit.Paint();
|
||||||
blur = this.CanvasKit.ImageFilter.MakeBlur(shape.blur.value, shape.blur.value, this.CanvasKit.TileMode.Decal, null);
|
|
||||||
if (!shape.shadow) {
|
if (!shape.shadow) {
|
||||||
const blurRect = this.CanvasKit.RRectXY(
|
const blurRect = 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),
|
||||||
@ -137,6 +153,17 @@ class CanvasKit {
|
|||||||
paintBlur.delete()
|
paintBlur.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
paint.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCircle(canvas, shape) {
|
||||||
|
let blur = null
|
||||||
|
const paint = new this.CanvasKit.Paint();
|
||||||
|
paint.setAntiAlias(true);
|
||||||
|
paint.setBlendMode(this.getBlendModeFromObject(shape));
|
||||||
|
if (shape.blur) {
|
||||||
|
const paintBlur = new this.CanvasKit.Paint();
|
||||||
|
}
|
||||||
if (shape.shadow && (shape.shadow.length > 0)) {
|
if (shape.shadow && (shape.shadow.length > 0)) {
|
||||||
const paintShadow = new this.CanvasKit.Paint();
|
const paintShadow = new this.CanvasKit.Paint();
|
||||||
const [first] = shape.shadow
|
const [first] = shape.shadow
|
||||||
@ -145,19 +172,12 @@ class CanvasKit {
|
|||||||
const shadow = this.CanvasKit.ImageFilter.MakeDropShadowOnly(first['offset-x'], first['offset-y'], first.blur, first.blur, color, blur);
|
const shadow = this.CanvasKit.ImageFilter.MakeDropShadowOnly(first['offset-x'], first['offset-y'], first.blur, first.blur, color, blur);
|
||||||
const shadowRect = this.CanvasKit.RRectXY(
|
const shadowRect = 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,
|
0,
|
||||||
ry)
|
0)
|
||||||
paintShadow.setImageFilter(shadow)
|
paintShadow.setImageFilter(shadow)
|
||||||
canvas.drawRRect(shadowRect, paintShadow)
|
canvas.drawOval(shadowRect, paintShadow)
|
||||||
paintShadow.delete()
|
paintShadow.delete()
|
||||||
}
|
}
|
||||||
paint.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
drawCircle(canvas, shape) {
|
|
||||||
const paint = new this.CanvasKit.Paint();
|
|
||||||
paint.setAntiAlias(true);
|
|
||||||
paint.setBlendMode(this.getBlendModeFromObject(shape));
|
|
||||||
// Drawing fills
|
// Drawing fills
|
||||||
if (shape.fills) {
|
if (shape.fills) {
|
||||||
for (const fill of shape.fills.reverse()) {
|
for (const fill of shape.fills.reverse()) {
|
||||||
@ -192,7 +212,6 @@ class CanvasKit {
|
|||||||
canvas.drawOval(rr, paint);
|
canvas.drawOval(rr, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let blur = null
|
|
||||||
if (shape.blur) {
|
if (shape.blur) {
|
||||||
const paintBlur = new this.CanvasKit.Paint();
|
const paintBlur = new this.CanvasKit.Paint();
|
||||||
blur = this.CanvasKit.ImageFilter.MakeBlur(shape.blur.value, shape.blur.value, this.CanvasKit.TileMode.Decal, null);
|
blur = this.CanvasKit.ImageFilter.MakeBlur(shape.blur.value, shape.blur.value, this.CanvasKit.TileMode.Decal, null);
|
||||||
@ -206,20 +225,6 @@ class CanvasKit {
|
|||||||
paintBlur.delete()
|
paintBlur.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shape.shadow && (shape.shadow.length > 0)) {
|
|
||||||
const paintShadow = new this.CanvasKit.Paint();
|
|
||||||
const [first] = shape.shadow
|
|
||||||
const color = this.CanvasKit.parseColorString(first.color.color)
|
|
||||||
color[3] = first.color.opacity
|
|
||||||
const shadow = this.CanvasKit.ImageFilter.MakeDropShadowOnly(first['offset-x'], first['offset-y'], first.blur, first.blur, color, blur);
|
|
||||||
const shadowRect = this.CanvasKit.RRectXY(
|
|
||||||
this.CanvasKit.LTRBRect(shape.x, shape.y, shape.x + shape.width, shape.y + shape.height),
|
|
||||||
0,
|
|
||||||
0)
|
|
||||||
paintShadow.setImageFilter(shadow)
|
|
||||||
canvas.drawOval(shadowRect, paintShadow)
|
|
||||||
paintShadow.delete()
|
|
||||||
}
|
|
||||||
paint.delete();
|
paint.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user