Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I put this function into a form element button?
    primarykey
    data
    text
    <p>I have a form element in my HTML page that currently retrieves the <code>toDataURL()</code> from one canvas(<code>canvas2</code>) and draws the image into a second canvas(<code>outputCanvas</code>). What I need is for that onclick event to retrieve the canvas image and use that image in this function. As of now Im able to manually save the canvas image as a .png and then hard-code the file into this function, but I need this all to happen when the button is clicked. Im a newb at .js but I can handle pseudo-code if its easier to explain, but please be specific. The following <code>draw()</code> needs to be handled when the click occurs. I have the listener below that should call the <code>draw()</code>. </p> <pre><code>function init () { canvas = document.getElementById('anotherCanvas'); ctx = canvas.getContext('2d'); draw (); } function draw() { img = new Image(); img.src = 'recursed1.png'; fr1 = makeFrame(ctx,makeVect(400,0), makeVect(400, 0), makeVect(0, 400)); img.onload = function(){ ctx.save(); newPainter = cornerSplit(imagePainter,5); newPainter(fr1); ctx.restore(); ctx.save(); newPainter(flipHorizLeft(fr1)); ctx.restore(); ctx.save(); newPainter(flipVertDown(fr1)); ctx.restore(); ctx.save(); newPainter(flipVertDown(flipHorizLeft(fr1))); } </code></pre> <p>The following is currently independent of the above, I can only get the above function to work if I manually save &amp; hard-code the image created in an independent canvas (canvas2). I need the two to work together. The HTML element:</p> <pre><code>&lt;input type="button" id="recImage" value="Recurse Image"&gt; var formElement = document.getElementById("createImageData"); formElement.addEventListener('click', createImageDataPressed, false); function createImageDataPressed(e) { var imageDataDisplay = document.getElementById("imageDataDisplay"); imageDataDisplay.value = canvas2.toDataURL(); var newImagewindow.open(canvas2.toDataURL(), "canvasImage","right=300,top=400,width="canvas2.width + ",height=" + canvas2.height + ",toolbar=0,resizable=0"); } </code></pre> <p>The above is my most recent attempt, it doesn't work... Nothing is set in stone, and If there is a better route than what Im attempting please let me know. <a href="http://mcgrawtheseeker.com/" rel="nofollow">this work in progress may help you understand what Im trying to do</a></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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