konvajs根据数组值

时间:2018-10-29 16:01:09

标签: jquery konvajs

我正在尝试将每个图像上的数组的值设置为'id'

       var pics = ["http://konvajs.github.io/assets/lion.png", "http://konvajs.github.io/assets/monkey.png"];
       var imgID = ["73", "70"];

        // Count total items in array
        var count = 0;
        pics.forEach(function() {
          count++;
        });

        for(var l = 0; l < count; l++) { 

            var src   = pics[l];

              // create new Konva.Image from src attribute
              Konva.Image.fromURL(src, function(image) {
                  image.setAttrs({
                      draggable: true,
                      id: imgID[l],
                      x: Math.random() * stage.width(),
                      y: Math.random() * stage.height(),
                  });

https://jsfiddle.net/6tnb2q2q/42/

0 个答案:

没有答案