以下是Konvajs库加载图片的示例:
org.slf4j.impl.StaticLoggerBinder
为什么它一直记录未捕获的TypeError:无法执行' createPattern' on' CanvasRenderingContext2D':提供的值不是'(HTMLImageElement或HTMLVideoElement或HTMLCanvasElement或ImageBitmap)'
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;