From 7e04a5fc5a513f3ac19a68fe18629a1e044e6808 Mon Sep 17 00:00:00 2001 From: CPPAlien Date: Mon, 21 Jan 2019 15:03:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E9=9D=A2=E6=94=AF=E6=8C=81=20shadow?= =?UTF-8?q?=20=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pen.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/pen.js b/lib/pen.js index 1a1a9fa..9ae97d3 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -198,6 +198,7 @@ export default class Painter { if (!notClip && view.css && view.css.borderRadius) { this._doClip(view.css.borderRadius, width, height); } + this._doShadow(view); return { width: width, @@ -354,20 +355,20 @@ export default class Painter { } else { this.ctx.setFillStyle(view.css.color); } - this._doBoxShadow(view); this.ctx.fillRect(-(width / 2), -(height / 2), width, height); this.ctx.restore(); 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){ + + // shadow 支持 (x, y, blur, color), 不支持 spread + // shadow:0px 0px 10px rgba(0,0,0,0.1); + _doShadow(view) { + if(!view.css || !view.css.shadow){ return; } - let box = view.css.boxShadow.replace(/,\s+/g, ',').split(' '); + let box = view.css.shadow.replace(/,\s+/g, ',').split(' '); if(box.length > 4) { - console.error('boxShadow don\'t spread option'); + console.error('shadow don\'t spread option'); return; } this.ctx.shadowOffsetX = parseInt(box[0])