angelali
11-22-2012, 03:53 PM
OK LOL, well, I want to know why when I save a canvas, the background is still transparent when I did give it a background color in CSS?
My codes was to write on a Canvas. I don't have issues in it. I only have issues about the background which is still transparent after right click on the canvas to save.
HTML
<canvas id="canvas" width="200" height="200"></canvas>
<img id="canvassave" alt="Right click to save me!">
<input type="text" size="25" id="lol"/>
<input type="button" value="write" onClick="writethecrap();"/>
CSS
#canvas {
background:red;
}
JavaScript
function writethecrap () {
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var loltext = document.getElementById("lol").value;
var dataURL = canvas.toDataURL();
document.getElementById('canvassave').src = dataURL;
context.fillText(loltext, 50, 50);
}
Bear in mind, the text is being written, only when I save the Canvas after right-click, the background is not saving. It is transparent.
My codes was to write on a Canvas. I don't have issues in it. I only have issues about the background which is still transparent after right click on the canvas to save.
HTML
<canvas id="canvas" width="200" height="200"></canvas>
<img id="canvassave" alt="Right click to save me!">
<input type="text" size="25" id="lol"/>
<input type="button" value="write" onClick="writethecrap();"/>
CSS
#canvas {
background:red;
}
JavaScript
function writethecrap () {
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var loltext = document.getElementById("lol").value;
var dataURL = canvas.toDataURL();
document.getElementById('canvassave').src = dataURL;
context.fillText(loltext, 50, 50);
}
Bear in mind, the text is being written, only when I save the Canvas after right-click, the background is not saving. It is transparent.