kineticjs

Create a rectangle with mousedown event in KineticJS

社会主义新天地 提交于 2019-12-01 11:15:26
问题 I am trying to create a rectangle shape using KineticJS with mousedown and drag events but not having much luck with it. Has anyone done anything similar? 回答1: http://jsfiddle.net/AYHSM/6/ var stage = new Kinetic.Stage({ container: 'container', width: 600, height: 400 }); var layer = new Kinetic.Layer(); layer.add(new Kinetic.Rect({ x:0, y:0, width:600, height:400 })); // this rect will allow us to use mouse events on the layer. There's probably a better way to do this, but I don't know it.

KineticJS canvas modified by CamanJS

自古美人都是妖i 提交于 2019-12-01 10:41:09
问题 I'm trying to apply CamanJS filter to a canvas created with KineticJS. It works: Caman("#creator canvas", function() { this.lomo().render(); }); After applying a CamanJS filter I'm trying to do sth with canvas (eg. drag and move layer or just click on it), but then the canvas reverts to its original state (before applying CamanJS filter). So the question is: how to "tell" KineticJS to update cache(?) or do sth like stage.draw() to keep new canvas data? Here is jsfiddle (click on "apply filter

How to extend KineticJS shape

空扰寡人 提交于 2019-12-01 07:28:33
问题 For KineticJS version 4.0.0 or less a shape extended a class and could be extended by var MyCircle = Kinetic.Circle.extend({ init : function(config) { this._super(config)); }, myFunc : function(){} }); Or Kinetic.MyCircle = function (config) { Kinetic.Circle.apply(this, [config]); }; Kinetic.MyCircle .prototype = { myFunc: function () {} }; Kinetic.GlobalObject.extend(Kinetic.MyCircle , Kinetic.Circle); In version 4.0.1 they removed the dependencies to the class utility and implemented a

How to crop an image with canvas and Kinetic.js

柔情痞子 提交于 2019-12-01 06:48:33
my function draw an image, and another image on another layer with Kinetic.js but i want to crop the second image which is named smsTopBg_image window.onload = function() { //INITIALISATION var stage = new Kinetic.Stage({ container: "iPhone", width: 480, height: 720 }); //LAYERS var background_layer = new Kinetic.Layer(); var sms_layer = new Kinetic.Layer(); var text_layer = new Kinetic.Layer(); //ELEMENTS var iPhoneBg = new Image(); iPhoneBg.onload = function() { var iPhoneBg_image = new Kinetic.Image({ image: iPhoneBg }); background_layer.add(iPhoneBg_image); stage.add(background_layer); }

Performance slow with kineticjs

会有一股神秘感。 提交于 2019-12-01 01:02:01
Sorry if this question was asked already, I've tried to find it by couldn't. I have a canvas that should eventually show about 400-500 rectangles 20-30 pixels height/width. Each one of them should move one pixel left and up on mouse over and back on mouse out to create sort of selected behavior. Now, my code works great with small amount of shapes, but for 500 of them it starts slowing down dramatically. From some example on the internet I saw that I can create "animation layer" and move the object i need to animate there. But, this still requires me to redraw the main layer to remove the

Preload font HTML5, JS, Kinetic.js?

我与影子孤独终老i 提交于 2019-12-01 00:50:42
I have a custom font ( *.ttf ), that I am using to write text on the HTML canvas using Kinetic.js. Unfortunately, on the first loading of the page it is not using my custom font, when reloading the page all is good. Can I preload the font somehow? I have tried this, but still not working: <link rel="prefetch" href="resource/font/IDAutomationHC39M.ttf"> Can I tell Kinetic.js to preload it somehow? The font is defined in my CSS like this: @font-face { font-family: "Barcode"; src: url(../font/IDAutomationHC39M.ttf); } Thanks in advance for your support! I had a same problem today.. I ended up

Preload font HTML5, JS, Kinetic.js?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 19:41:13
问题 I have a custom font ( *.ttf ), that I am using to write text on the HTML canvas using Kinetic.js. Unfortunately, on the first loading of the page it is not using my custom font, when reloading the page all is good. Can I preload the font somehow? I have tried this, but still not working: <link rel="prefetch" href="resource/font/IDAutomationHC39M.ttf"> Can I tell Kinetic.js to preload it somehow? The font is defined in my CSS like this: @font-face { font-family: "Barcode"; src: url(../font

Performance slow with kineticjs

一曲冷凌霜 提交于 2019-11-30 19:10:03
问题 Sorry if this question was asked already, I've tried to find it by couldn't. I have a canvas that should eventually show about 400-500 rectangles 20-30 pixels height/width. Each one of them should move one pixel left and up on mouse over and back on mouse out to create sort of selected behavior. Now, my code works great with small amount of shapes, but for 500 of them it starts slowing down dramatically. From some example on the internet I saw that I can create "animation layer" and move the

Saving the html 5 canvas image on local harddrive

让人想犯罪 __ 提交于 2019-11-30 15:57:01
问题 I had created shapes on html 5 canvas using kineticjs library. Now i want to save the canvas as an image on my local system harddrive. Pls tell me how can i achieve it by using KineticJS library. 回答1: After selecting the canvas (using something like document.getElementById I guess), you should be able to call the following to convert the canvas into a dataURL. Once you've got that URL, open it in another browser window and do a standard Right Click->Save Image As, and save it as a JPG/PNG/etc

Saving the html 5 canvas image on local harddrive

痞子三分冷 提交于 2019-11-30 15:15:10
I had created shapes on html 5 canvas using kineticjs library. Now i want to save the canvas as an image on my local system harddrive. Pls tell me how can i achieve it by using KineticJS library. After selecting the canvas (using something like document.getElementById I guess), you should be able to call the following to convert the canvas into a dataURL. Once you've got that URL, open it in another browser window and do a standard Right Click->Save Image As, and save it as a JPG/PNG/etc. var canvas = document.getElementById("mycanvas"); var img = canvas.toDataURL("image/png"); Whether or not