为什么我不能在Konva.Shape.fillPatternImage(imageObj)中使用Konva.Image()?

时间:2016-01-07 15:08:10

标签: javascript html5 canvas html5-canvas kineticjs

以下是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;

  

1 个答案:

答案 0 :(得分:0)

fillPatternImage使用原生Image对象。

http://konvajs.github.io/docs/styling/Fill.html