Solved

jQuery ui draggable: saving to canvas

Posted on 2014-10-27
2
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

624 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