fix: 修复渐变效果时圆角无效问题

This commit is contained in:
CPPAlien 2019-11-06 18:48:23 +08:00
parent 7e6ebf4878
commit 91fa810503
2 changed files with 5 additions and 4 deletions

View File

@ -39,8 +39,8 @@
for (let i = 0; i < colorPer.colors.length; i++) { for (let i = 0; i < colorPer.colors.length; i++) {
grd.addColorStop(colorPer.percents[i], colorPer.colors[i]); grd.addColorStop(colorPer.percents[i], colorPer.colors[i]);
} }
ctx.setFillStyle(grd); ctx.fillStyle = grd;
ctx.fillRect(-(width / 2), -(height / 2), width, height); //ctx.fillRect(-(width / 2), -(height / 2), width, height);
} }
function analizeLinear(bg, width, height) { function analizeLinear(bg, width, height) {
@ -93,8 +93,8 @@
for (let i = 0; i < colorPer.colors.length; i++) { for (let i = 0; i < colorPer.colors.length; i++) {
grd.addColorStop(colorPer.percents[i], colorPer.colors[i]); grd.addColorStop(colorPer.percents[i], colorPer.colors[i]);
} }
ctx.setFillStyle(grd); ctx.fillStyle = grd
ctx.fillRect(-(width / 2), -(height / 2), width, height); //ctx.fillRect(-(width / 2), -(height / 2), width, height);
} }
module.exports = { api } module.exports = { api }

View File

@ -43,6 +43,7 @@ export default class Painter {
this.ctx.fillRect(-(width / 2), -(height / 2), width, height); this.ctx.fillRect(-(width / 2), -(height / 2), width, height);
} else if (GD.api.isGradient(bg)) { } else if (GD.api.isGradient(bg)) {
GD.api.doGradient(bg, width, height, this.ctx); GD.api.doGradient(bg, width, height, this.ctx);
this.ctx.fillRect(-(width / 2), -(height / 2), width, height);
} else { } else {
// 背景填充图片 // 背景填充图片
this.ctx.drawImage(bg, -(width / 2), -(height / 2), width, height); this.ctx.drawImage(bg, -(width / 2), -(height / 2), width, height);