kineticjs

html canvas trap left click and allow right click to pass through (pointer-events)

折月煮酒 提交于 2020-01-06 15:31:29
问题 The use case is that I have an html canvas on top of several html elements which listen for right click mouse events. I want to draw on the canvas using left mouse button, and at the same time interact with underlying html elements using right click. I get that I can allow all mouse events to pass through the canvas by setting css property pointer-events to none. However I want to allow only right click to pass through it. One way to achieve this may be to listen on the canvas for right click

KineticJS - replacing image within a group

大兔子大兔子 提交于 2020-01-06 10:21:36
问题 Please see this Link When the canvas loads there are 2 images: Yoda and Darth Vader. I want to be able to click on Yoda (to select it) and then click on the "change" button under the canvas. This button click should replace Yoda with Darth Vader and still keep the "2nd" Darth Vader selected. My code is as follows: function replaceImage(i, callback) { selectedGroup.destroy(); var images = {}; images[i] = new Image(); images[i].onload = function() { callback(i,images); }; images[i].src =

KineticJS - replacing image within a group

二次信任 提交于 2020-01-06 10:21:32
问题 Please see this Link When the canvas loads there are 2 images: Yoda and Darth Vader. I want to be able to click on Yoda (to select it) and then click on the "change" button under the canvas. This button click should replace Yoda with Darth Vader and still keep the "2nd" Darth Vader selected. My code is as follows: function replaceImage(i, callback) { selectedGroup.destroy(); var images = {}; images[i] = new Image(); images[i].onload = function() { callback(i,images); }; images[i].src =

Is it possible to avoid “The operation is insecure” when using Canvas?

蓝咒 提交于 2020-01-06 01:07:12
问题 I have a HTML canvas (using KineticJS, however canvas aficionados should still chime in) that loads an image from another domain, places it onto the canvas and overlays some other information to product a final image. When I try to use canvas.toDataURL () to output the file, I receive the message "The operation is insecure.", obviously due to cross-domain restrictions. I was wondering if anyone knows of any methods to work around this error (preferably cross-browser compatible). I was

Is it possible to avoid “The operation is insecure” when using Canvas?

风格不统一 提交于 2020-01-06 01:06:46
问题 I have a HTML canvas (using KineticJS, however canvas aficionados should still chime in) that loads an image from another domain, places it onto the canvas and overlays some other information to product a final image. When I try to use canvas.toDataURL () to output the file, I receive the message "The operation is insecure.", obviously due to cross-domain restrictions. I was wondering if anyone knows of any methods to work around this error (preferably cross-browser compatible). I was

KineticJS - Performance Difference Between Kinetic.Group.listening() and Individual Kinetic.Node.listening()

做~自己de王妃 提交于 2020-01-05 10:52:50
问题 Is there any performance difference between this: var rect1 = new Kinetic.Rect({ listening: false }), rect2 = new Kinetic.Rect({ listening: false }), group = new Kinetic.Group; group.add( rect1 ); group.add( rect2 ); ... and this: var rect1 = new Kinetic.Rect, rect2 = new Kinetic.Rect, group = new Kinetic.Group({ listening: false }); group.add( rect1 ); group.add( rect2 ); If so, why? 来源: https://stackoverflow.com/questions/24592127/kineticjs-performance-difference-between-kinetic-group

Kinetic.js [How can I stop one sprite]

纵饮孤独 提交于 2020-01-04 07:02:32
问题 I´m starting with Kinetic.js and I have my first app working perfectly, but I don´t find the way to stop sprites... for example, I have one sprite and I want to "play" that sprite just once, see the frames and in the last one, one simple stop(). How can I do that? (Stop after the last "frame" of the sprite). Here´s my code (for that sprite): var myImage = new Image(); myImage.onload = function() { var mySprite = new Kinetic.Sprite({ x: 250, y: 40, width: 70, height: 109, image: myImage,

Kinetic.js [How can I stop one sprite]

风格不统一 提交于 2020-01-04 07:02:14
问题 I´m starting with Kinetic.js and I have my first app working perfectly, but I don´t find the way to stop sprites... for example, I have one sprite and I want to "play" that sprite just once, see the frames and in the last one, one simple stop(). How can I do that? (Stop after the last "frame" of the sprite). Here´s my code (for that sprite): var myImage = new Image(); myImage.onload = function() { var mySprite = new Kinetic.Sprite({ x: 250, y: 40, width: 70, height: 109, image: myImage,

Google Closure and generated getters/setters

只谈情不闲聊 提交于 2020-01-04 02:34:07
问题 I'm trying to get KineticJS to work with Google Closure Compiler. KineticJS, however, generated it's getters & setters based on the name of the variables. Something like this: // add getter and setter methods Kinetic.Node.addSetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addSetter(constructor, attr); } }; Kinetic.Node.addGetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addGetter

How does the inheritance model of KineticJS work?

﹥>﹥吖頭↗ 提交于 2020-01-04 02:34:07
问题 I am a little new to JavaScript, and I know that there are different inheritance models that can be used. I have a project I used KineticJS for and I noticed in their changelog that they changed the inheritance model with the release of v3.10.3 of the project, so that we can 'more easily extend or add custom methods to Kinetic classes' I have done some searching for this, but I cannot seem to find a clear example of this anywhere. I was wondering if anyone could tell me what would be the