mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 08:22:44 +08:00
fix incorrect display when no fill or stroke
This commit is contained in:
parent
1acfa9ebf7
commit
e3f1d1c95b
@ -2,7 +2,10 @@ import { Util } from '../Util';
|
|||||||
import { Factory } from '../Factory';
|
import { Factory } from '../Factory';
|
||||||
import { Shape, ShapeConfig } from '../Shape';
|
import { Shape, ShapeConfig } from '../Shape';
|
||||||
import { _registerNode } from '../Global';
|
import { _registerNode } from '../Global';
|
||||||
import { getNumberOrArrayOfNumbersValidator, getNumberValidator } from '../Validators';
|
import {
|
||||||
|
getNumberOrArrayOfNumbersValidator,
|
||||||
|
getNumberValidator,
|
||||||
|
} from '../Validators';
|
||||||
|
|
||||||
import { GetSet, IRect } from '../types';
|
import { GetSet, IRect } from '../types';
|
||||||
import { Context } from '../Context';
|
import { Context } from '../Context';
|
||||||
@ -91,7 +94,7 @@ export class Image extends Shape<ImageConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasFill() || this.hasStroke()) {
|
if (this.hasFill() || this.hasStroke() || cornerRadius) {
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
cornerRadius
|
cornerRadius
|
||||||
? Util.drawRoundedRectPath(context, width, height, cornerRadius)
|
? Util.drawRoundedRectPath(context, width, height, cornerRadius)
|
||||||
@ -101,13 +104,10 @@ export class Image extends Shape<ImageConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (image) {
|
if (image) {
|
||||||
// context.save();
|
|
||||||
if (cornerRadius) {
|
if (cornerRadius) {
|
||||||
// Util.drawRoundedRectPath(context, width, height, cornerRadius);
|
|
||||||
context.clip();
|
context.clip();
|
||||||
}
|
}
|
||||||
context.drawImage.apply(context, params);
|
context.drawImage.apply(context, params);
|
||||||
// context.restore();
|
|
||||||
}
|
}
|
||||||
// If you need to draw later, you need to execute save/restore
|
// If you need to draw later, you need to execute save/restore
|
||||||
}
|
}
|
||||||
|
@ -385,4 +385,32 @@ describe('Image', function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.only('corner radius', function (done) {
|
||||||
|
loadImage('darth-vader.jpg', (imageObj) => {
|
||||||
|
var stage = addStage();
|
||||||
|
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
var darth = new Konva.Image({
|
||||||
|
x: 20,
|
||||||
|
y: 20,
|
||||||
|
image: imageObj,
|
||||||
|
cornerRadius: 10,
|
||||||
|
draggable: true,
|
||||||
|
stroke: 'red',
|
||||||
|
strokeWidth: 100,
|
||||||
|
strokeEnabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.add(darth);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
layer.getContext().getTrace(true),
|
||||||
|
'clearRect();save();transform();beginPath();moveTo();lineTo();arc();lineTo();arc();lineTo();arc();lineTo();arc();closePath();clip();drawImage();restore();'
|
||||||
|
);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user