Skip to content

Commit

Permalink
fix: fix issue with image stroke clip
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Jan 2, 2025
1 parent fc7d7d1 commit 683dbe2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,6 @@ export class DefaultCanvasImageRender extends BaseRender<IImage> implements IGra
if (fillCb) {
fillCb(context, image.attribute, imageAttribute);
} else if (fVisible) {
if (!url || !image.resources) {
return;
}
const res = image.resources.get(url);
if (res.state !== 'success') {
return;
}

// deal with cornerRadius
let needRestore = false;
if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {
// 不需要处理圆角
} else {
context.beginPath();
createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');
context.save();
context.clip();
needRestore = true;
}

context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
let repeat = 0;
if (repeatX === 'repeat') {
Expand Down
23 changes: 10 additions & 13 deletions packages/vrender/__tests__/browser/src/pages/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ export const page = () => {
shapes.push(svgImage);

const image = createImage({
x: 500,
y: 100,
width: 100,
height: 100,
image: urlPng,
cornerRadius: 100,
// stroke: 'green',
// lineWidth: 10,
outerBorder: {
distance: 50,
lineWidth: 100,
stroke: 'pink'
}
x: 50,
y: 50,
width: 200,
height: 200,
lineWidth: 10,
cornerRadius: 14,
stroke: '#000000',
fill: 'transparent',
image:
'http://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/vchart-editor/upload-images/014d69b2-2731-4daa-9e60-68925fa1e54b.jpg'
});
shapes.push(image);

Expand Down

0 comments on commit 683dbe2

Please sign in to comment.