问题
The following is an example from Konvajs library to load an image:
var imageObj = new Image();
imageObj.onload = function() {
var yoda = new Konva.Image({
x: 50,
y: 50,
image: imageObj,
width: 106,
height: 118
});
And here is my code
var annotation = new Konva.Line({
points: this.contour,
stroke: color,
closed: true,
strokeWidth: 1
});
var nativeImageObject = new Image();
nativeImageObject.onload = function() {
var konvaImage = new Konva.Image({
image: nativeImageObject
});
annotation.fillPatternImage(konvaImage);
DentalChart.Pattern.customPatternImages.push(customPatternImage);
gridLayer.add(annotation);
stage.draw();
};
nativeImageObject.src = pattern.toDataURL();
nativeImageObject.id = patternEnum + '' + color;
回答1:
For fillPatternImage
use native Image
object.
http://konvajs.github.io/docs/styling/Fill.html
来源:https://stackoverflow.com/questions/34658539/why-i-cannot-use-konva-image-in-konva-shape-fillpatternimageimageobj