Solved

jQuery ui draggable: saving to canvas

Posted on 2014-10-27
2
256 Views
Last Modified: 2014-10-28
I have a product image (prodimage) and with a button click I can add it to a canvas. For now both the product image and the canvas are on the same html page.

function CanvasIt() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("prodimage");
ctx.drawImage(img, 10, 10);
};

Open in new window


I also have some draggable images and after the are positioned over the prodimage I would like to add them to the same canvas.

<script type="text/javascript">
$(function() {
	
	$("#graphicCount11").draggable({ 
		containment: "#product-image-wrapper", 
		scroll: false,
		stop: function(event, ui) {
		   };
	 });
</script>

Open in new window


Anyone have an idea of how this can be done?
0
Comment
Question by:Gary Samuels
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40407559
test page : http://jsfiddle.net/rt20paok/

jQuery(document).ready(function() {
    CanvasIt();
	$("#graphicCount11").draggable({ 
		containment: "#product-image-wrapper", 
		scroll: false,
		stop: function(event, ui) {
            var c = document.getElementById("myCanvas");
            var ctx = c.getContext("2d");
            var img = $(this).get(0);
            ctx.drawImage(img, 10, 10);
        }
	 });
});

function CanvasIt() {
    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");
    var img = document.getElementById("prodimage");
    ctx.drawImage(img, 10, 10);
};

Open in new window

0
 

Author Closing Comment

by:Gary Samuels
ID: 40409123
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now