Is it possible to make every line that I draw draggable in Canvas?

omnigraffle draw line without connection
javascript draw line between two points
omnigraffle custom shape
create a drawing app with html5 canvas and javascript
omnigraffle fill shape
html5 canvas draw line with mouse
omnigraffle pen tool
html5 canvas draw shapes with mouse

This is my Javascript

 var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');

canvas.addEventListener('click', drawLine, false);
var clicks = 0;
var lastClick = [0, 0];

$(function() {
  $.each(['#f00', '#ff0', '#0f0', '#0ff', '#00f', '#f0f', '#000', '#fff'], function() {
                $('#tools').append("<a href='#' onclick=\"context.strokeStyle = '" + this + "';return false;\" style='width: 10px; background: " + this + ";'></a> ");
              });


});


function getCursorPosition(e) {
    var x;
    var y;

    if (e.pageX != undefined && e.pageY != undefined) {
        x = e.pageX;
        y = e.pageY;
    } else {
        x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    }

    return [x, y];
}

function drawLine(e) {
    //context = this.getContext('2d');

    x = getCursorPosition(e)[0] - this.offsetLeft;
    y = getCursorPosition(e)[1] - this.offsetTop;

    if (clicks != 1) {
        clicks++;
    } else {
        context.beginPath();
        context.moveTo(lastClick[0], lastClick[1]);
        context.lineTo(x, y, 6);

       // context.strokeStyle = '#000000';
        context.stroke();


        clicks = 0;
    }

    lastClick = [x, y];
};

This HTML

<div id='tools'>
          </div>
 <canvas id="canvas" width="500" height="500"></canvas>

I want to generate a new DIV when I finish drawing the line, and make it draggable, how can I do it? I not sure how can contain the line inside the DIV.

The Div should be create when I stop drawing one line.

This is the Jfiddle for a clearer picture

http://jsfiddle.net/pVZzY/1/

I suggest kinetic.js for this task. Take a look at it http://kineticjs.com/

This will surely make your intended job much easier

making each canvas line draggable and droppable, I am able to draw some lines on the canvas. I want to make each line draggable and droppable. However, it is implemented by storing the positions of different� I won’t attempt to explain every line of the HTML and JavaScript code used in this example; instead you may find it instructive to simply download the commented source and study it carefully. The basics of creating a canvas application can be found in several books; the basic setup I am using here is covered very carefully in HTML5 Canvas by

Canvas doesn't allow you to alter/move/scale the objects that you've just draw. Think of it as paper sheet that you color up with pencils, you can't move the pencil line around the only way is to erase the old line and draw a new one - same goes for canvas.

But! There are a bunch of libraries that make working with canvas easier, one of which is http://kineticjs.com/, another one is http://paperjs.org/. I can't claim for kineticjs, but seems it's similar to paper.js in the way that they both create an Object layer.

Briefly speaking - they provide you with API to create and change scene objects (images, lines, shapes) and deal with draw-clear-redraw Canvas concept at the backstage.

Office 2003 All-in-One Desk Reference For Dummies, The drawing canvas is meant to help you place objects such as lines and shapes draw your line or shape outside the canvas or, if you've already drawn it, drag it toolbar to make the canvas as large as it needs to be to take in all objects. use JQuery draggable because the draggable in the future you can use it with backend and it will be flexible with jq , canvas use it in game or something like that not in functionality like draggable

Microsoft Word 2010 In Depth, Portable Documents, To move pieces of the drawing within the drawing canvas, simply drag and drop them. The same skills work here as for lines and shapes that you draw yourself. Drawing object, but you can almost get it back to normal by grouping all the� For example, <Line Stroke="Red" X2="400"/> defines a horizontal line that is 400 pixels long. The other X,Y properties are 0 by default, so in terms of points this XAML would draw a line from (0,0) to (400,0). You could then use a TranslateTransform to move the entire Line, if you wanted it to start at a point other than (0,0).

Adobe Creative Suite 3 Web Premium All-in-One Desk Reference For , Click the Dodge tool and click and drag on the canvas to lighten an area of a bitmap image. tools (clockwise from top left) make up the Vector section of the Tools panel: • Line tool: With the Line tool, you can draw a straight line every time. Step 1 - Making an Object Draggable. Here are steps to be taken − If you want to drag an element, you need to set the draggable attribute to true for that element. Set an event listener for dragstart that stores the data being dragged. The event listener dragstart will set the allowed effects (copy, move, link, or some combination).

Macromedia Studio 8 All-in-One Desk Reference For Dummies, Click the Dodge tool and click and drag on the canvas to lighten an area of a bitmap image. tools (clockwise from top left) make up the Vector section of the Tools panel: • Line tool: With the Line tool, you can draw a straight line every time. In the code example, we draw simple lines. canvas.create_line(15, 25, 200, 25) The parameters of the create_line method are the x and y coordinates of the start and end points of the line. canvas.create_line(300, 35, 300, 200, dash=(4, 2)) A vertical line is drawn. The dash option specifies the dash pattern of the line. We have a line

Macromedia Studio MX 2004 All-in-One Desk Reference For Dummies, Click the Dodge tool and click and drag on the canvas to lighten an area of a bitmap image. top left) make up the Vector section of the Tools panel: Line tool: Throw your ruler away! With the Line tool, you can draw a straight line every time. The way the program works is to draw the lines in the Paint event handler. The first loop makes every line red. If you want different colors, you’ll need some data structure to store each line’s color. For example, you could use a list of colors where the k-th entry corresponds to the k-th line.