Re: print copy of image when drag the original image

Thursday, January 8, 2015

I cannot grok exactly by what you mean by "i want to print a copy of image at perticular x,y coordinate", but I assume this is what you want. 

In your code below, please see statement prefixed by /*Added by JAL*/

On Wednesday, January 7, 2015 at 12:07:43 PM UTC-5, Biruntha Gnaneswaran wrote:
Hi, when dragging the image within the container i want to print a copy of image at perticular x,y coordinate and previous drawn image should be erase how can i do this?please help me...

<!DOCTYPE html>
    <meta charset="utf-8">
    <script type="text/javascript" src=""></script>
    <script src=""></script>
    <script src=""></script>
      border:solid 1px #ccc;
      margin-top: 10px;
      border:solid 1px blue;

    // get a reference to the house icon in the toolbar
    // hide the icon until its image has loaded
    var $house=$("#house");

    // get the offset position of the kinetic container
    var $stageContainer=$("#container");
    var stageOffset=$stageContainer.offset();
    var offsetX=stageOffset.left;

    // create the Kinetic.Stage and layer
    var stage = new Kinetic.Stage({
        container: 'container',
        width: 350,
        height: 350
    var layer = new Kinetic.Layer();

    // start loading the image used in the draggable toolbar element
    // this image will be used in a new Kinetic.Image
    var image1=new Image();

    // make the toolbar image draggable

    // set the data payload
    $"url","house.png"); // key-value pair
    $"width","32"); // key-value pair
    $"height","33"); // key-value pair
    $"image",image1); // key-value pair

    // make the Kinetic Container a dropzone

    // handle a drop into the Kinetic container
    function dragDrop(e,ui){

        // get the drop point
        var x=parseInt(ui.offset.left-offsetX);
        var y=parseInt(;

        // get the drop payload (here the payload is the image)
        var element=ui.draggable;

        // create a new Kinetic.Image at the drop point
        // be sure to adjust for any border width (here border==1)
        var image = new Kinetic.Image({
            draggable: true,
        // restrict to allow horizontal dragging only
        dragBoundFunc: function(pos) {
//            if(pos.x<this.minX){  pos.x=this.minX; }
//            this.minX=pos.x;
            return {
              x: pos.x,
              y: this.getAbsolutePosition().y
       //get image position.
            image.on("dragend", function() {
               var points = image.getPosition();
               //alert(points.x + ',' + points.y);
               var image1 = new Kinetic.Image({
                    name: data,
                    id: "imageantry",
                    x: points.x+65,
                    y: points.y,
                    image: theImage,
                    draggable: false
                    /* Added by JAL*/  image.remove();  /* END Added by JAL*/  
        image.on('dblclick', function() {

}); // end $(function(){});

    <div id="toolbar">
        <img id="house" width=32 height=32 src=""><br>
    <div id="container"></div>

You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit


Post a Comment

Note: Only a member of this blog may post a comment.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii