Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this below code</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.3.js"&gt;&lt;/script&gt; &lt;script&gt; window.onload = function() { var stage = new Kinetic.Stage({ container: "container", width: 1024, height: 768 }); var layer = new Kinetic.Layer(); var spaceShip = new Kinetic.Shape({ drawFunc: function (context) { context.beginPath(); context.moveTo(99.3, 161.4); context.bezierCurveTo(99.3, 143.2, 92.5, 128.4, 84.2, 128.4); context.bezierCurveTo(83.6, 128.4, 83.1, 128.4, 82.6, 128.6); context.bezierCurveTo(76.5, 84.1, 53.0, 8.0, 53.0, 8.0); context.bezierCurveTo(53.0, 8.0, 29.6, 84.0, 23.5, 128.5); context.bezierCurveTo(23.0, 128.4, 22.6, 128.4, 22.2, 128.4); context.bezierCurveTo(13.8, 128.4, 7.0, 143.2, 7.0, 161.4); context.bezierCurveTo(7.0, 179.6, 22.2, 228.9, 22.2, 228.9); context.bezierCurveTo(22.2, 228.9, 27.2, 212.4, 31.5, 194.9); context.bezierCurveTo(37.1, 206.7, 44.7, 213.9, 53.0, 213.9); context.bezierCurveTo(61.5, 213.9, 69.1, 206.5, 74.7, 194.6); context.bezierCurveTo(79.0, 212.2, 84.2, 228.9, 84.2, 228.9); context.bezierCurveTo(84.2, 228.9, 99.3, 179.6, 99.3, 161.4); context.closePath(); this.fill(context); this.stroke(context); }, draggable:true, fill: "#00D2FF", stroke: "black", strokeWidth: 1 }); // add the shape to the layer layer.add(spaceShip); // add the layer to the stage stage.add(layer); spaceShip.on('dragstart', function() { console.log("Drag start"); document.getElementById("display").innerHTML = "Drag start"; }); spaceShip.on('dragend', function() { console.log("Drag end"); document.getElementById("display").innerHTML = "Drag end"; }); }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt;&lt;/div&gt; &lt;div id="display"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload