rect 支持 boxShadow
rect 支持 boxShadow
This commit is contained in:
parent
8a34a81b2e
commit
d8f68282f2
17
lib/pen.js
17
lib/pen.js
@ -354,10 +354,27 @@ export default class Painter {
|
|||||||
} else {
|
} else {
|
||||||
this.ctx.setFillStyle(view.css.color);
|
this.ctx.setFillStyle(view.css.color);
|
||||||
}
|
}
|
||||||
|
this._doBoxShadow(view);
|
||||||
this.ctx.fillRect(-(width / 2), -(height / 2), width, height);
|
this.ctx.fillRect(-(width / 2), -(height / 2), width, height);
|
||||||
this.ctx.restore();
|
this.ctx.restore();
|
||||||
this._doBorder(view, width, height);
|
this._doBorder(view, width, height);
|
||||||
}
|
}
|
||||||
|
// box-shadow 支持 (x, y, blur, color), 不支持 spread
|
||||||
|
// box-shadow:0px 0px 10px rgba(0,0,0,0.1);
|
||||||
|
_doBoxShadow(view) {
|
||||||
|
if(!view.css.boxShadow){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let box = view.css.boxShadow.replace(/,\s+/g, ',').split(' ');
|
||||||
|
if(box.length > 4) {
|
||||||
|
console.error('boxShadow don\'t spread option');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.ctx.shadowOffsetX = parseInt(box[0])
|
||||||
|
this.ctx.shadowOffsetY = parseInt(box[1])
|
||||||
|
this.ctx.shadowBlur = parseInt(box[2])
|
||||||
|
this.ctx.shadowColor = box[3];
|
||||||
|
}
|
||||||
|
|
||||||
_getAngle(angle) {
|
_getAngle(angle) {
|
||||||
return Number(angle) * Math.PI / 180;
|
return Number(angle) * Math.PI / 180;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user