kineticjs

Constrained/Proportional Scaling in KineticJS

我怕爱的太早我们不能终老 提交于 2019-12-06 16:02:40
问题 When any of the 4 corner handles of the image is dragged, the image should scale proportionally either up or down. Problem: With my current attempt as shown in the jsfiddle linked below, when the topLeft handles are dragged vertically, the image rescales proportionally, but the other handles flicker. When the same topLeft handle is dragged horizontally, the image simply moves without resizing. How can proportional scaling be implemented with KineticJS? Thank you!!! jsfiddle: http://jsfiddle

kineticjs - mask/contain images so no overlap

孤人 提交于 2019-12-06 15:25:43
i have 2 images on my stage underneath an overlay image of 2 frames. The user can drag each image as if they were positioninng each image inside a photo frame. The problem i have is the yoda image in this example can overlap and appear inside the darth vader frame on the left (and vice-versa), as shown here: jsfiddle here: http://jsfiddle.net/vTLkn/ Is there a way of placing the images inside some form of container or rectangle to stop this so they cannot appear inside another 'frame'? The final page could end up having up to 5 or 6 frames and images with each image able to be scaled up or

KineticJS dynamically change the position of an object when other object is moved

人走茶凉 提交于 2019-12-06 15:13:18
I have a vertical and a horizontal lines and a circle on my stage, trying to keep the circle centered on the corssoing of the two lines when I move either line, here is my script that does not work: var cy = 512; var cx = 512; var gy = 0; var gx = 0; var stage1 = new Kinetic.Stage({ container: 'container', width: 1024, height: 1024 }); var layer = new Kinetic.Layer(); var circle = new Kinetic.Layer(); var circle1 = new Kinetic.Circle({ x: cx + gx, y: cy + gy, radius: 140, stroke: '#00ffff', strokeWidth: 4, opacity: 0.5 }); circle.add(circle1); var GreenLine1 = new Kinetic.Line({ points: [0,

How to rotate an image x degrees then move in that direction?

一曲冷凌霜 提交于 2019-12-06 14:37:47
问题 I'm a newbie to KineticJS and have been going through the tutorials. I want to take an image that has a 'front' and rotate it a random number of degrees and then have it move forward a number of pixels/inches in that new direction. I was able to use this rotation tutorial to rotate my image. I see how to use transitionTo to send an image to an x/y coordinate. I'm having trouble tying the two together. I feel like I need randomly generate e a new x/y coordinate and then determine the degree

How to get Children that have same type Kineticjs?

穿精又带淫゛_ 提交于 2019-12-06 13:34:14
问题 I have a trouble in Kineticjs, in my code: var G1=new Kinetic.Group() var sq=new Kinetic.Rect({ x:0, y:0, name:"sq" }) var line1=new Kinetic.Line({ Points:[0,0,10,10], name:"line1" }) var line2=new Kinetic.Line({ Points:[0,0,50,50], name:"line1" }) G1.add(sq).add(line1).add(line2) I know that to get the children from G1 just type "G1.getChildren()". But to get the children that has same type for example type Kinetic.Line I don't have any idea. Please help me, tahnks 回答1: sorry for not having

Export KinteticJS drawing to SVG?

瘦欲@ 提交于 2019-12-06 07:15:57
Is it possible to export Kinetic JS object to SVG? Or workaround is to convert Kintetic JS's canvas to SVG. EDIT: The best is to use fabricJS since it supports canvas to SVG rendering while working with fabric objects. I accepted Phrogz's answer since it also does conversion canvas to svg without using some other library for drawing on canvas. EDIT 2: OK, i messed up, Phrogz's library is wrapper around canvas element so you use it's methods to draw on canvas (I thought that it just 'listens' on canvas and creates SVG paths). So the best solution is fabricJS definitely. vale4674 The best

Canvas tooltip to appear outside canvas?

。_饼干妹妹 提交于 2019-12-06 06:22:26
问题 I have made the following using KineticJS and D3.js. I have used KineticJS to let me popup tooltips when the user hovers over one of the dots. However, the tooltip appears cut off because of the boundaries of the canvas. Is there a way I can make this appear without it getting clipped? The entire code itself is pretty huge and contains a lot of unrelated stuff so I posted the relevant snippets: this.stage = new Kinetic.Stage({ container: 'canvas', width: this.WIDTH, height: this.HEIGHT });

Detecting a Click on Stage but not on Shape in KineticJS

和自甴很熟 提交于 2019-12-06 05:26:06
问题 In KineticJS, how do you detect a Click event where the click occurs outside an object/shape? I am trying to get a Rect to change its scale to 2 when a user clicks on it, and return back to a scale of 1 when the user clicks anywhere outside it. JSfiddle: http://jsfiddle.net/ABTAD/8/ Managed to detect a click on stage, but clicking on the Rect also fires the click handler!!! And somehow the .setScale(1) does not do anything, while console.log printes something out. How can I prevent the click

KineticJS: right click fires click

℡╲_俬逩灬. 提交于 2019-12-06 04:05:15
I'm using Kineticjs and I'm defining a rect event like this this.rect.on('click tap', function(){ foo(); }); The event is fired when I left-click, but also when right-click. How can I avoid to fire this event with right-click? (I can't disabled the right-click in the page because I want to open a context menu if I rightclick over the rect) Thank you You need to filter out right mouse click this.rect.on('click tap', function(e){ // 1:left, 2: middle, 3: right, for IE 8, e.button != 2 if (e.which != 3) { foo(); } } 来源: https://stackoverflow.com/questions/15039915/kineticjs-right-click-fires

Combining three.js and KineticJS - 3D cube

霸气de小男生 提交于 2019-12-06 01:57:43
I am trying to add a 3D cube to Kinetic JS canvas to show the x,y,z rotation. I found this article http://www.tonicodes.net/blog/combining-three-js-and-kineticjs . I worked with version 3.8, When I tried to follow the example using the version 4 of Kinetic JS I got this error, Unable to get property 'appendChild' Any suggestions, to solve it or a better method to include 3D cube in the canvas. complete project http://jsfiddle.net/user373721/hXw6D/1/ I found this perfect example http://html5example.net/entry/html5-canvas/html5-canvas-pre3d-rotating-cube , unfortunately it is based on pre3d.js