0

I have set image property in Kineticjs

var img= new Image()
img.style.cssText = 'box-shadow: 10px 10px 5px #888888;'            
img.src = srclink[0];

      var tool=new Kinetic.Image({
         x: 0,
         y: 0,
         image: img,
         width: size[0],
         height: size[1],
         name: val["name"],
         id:val["cat"],

      })

all will work except the style because I hope the image will have the shadow

I hope you can help me, thanks.

4

1 回答 1

1

您不能使用 css 来设置画布元素的样式。但是您可以使用动力学 ( DEMO )添加阴影:

var tool=new Kinetic.Image({
     x: 0,
     y: 0,
     image: img,
     width: size[0],
     height: size[1],
     name: val["name"],
     id:val["cat"],
     shadowColor: '#888888',
     shadowBlur: 5,
     shadowOffset: 10,
     shadowOpacity: 1
});
于 2013-05-11T14:19:36.493 回答