Open
Description
Not really an issue. But not sure where else I could write this.
I wanted to use your script to create space wallpapers for myself.
Since the canvas context is webgl I needed to preserve the drawing buffer. Otherwise the canvas blob will be blank.
//addition to the canvas settings in bundle.js
var canvas = document.getElementById('render-canvas');
var glContextAttributes = { preserveDrawingBuffer: true };
var gl = canvas.getContext("experimental-webgl", glContextAttributes);
canvas.width = 2560; //window.innerWidth - (300 + 16 + 16 + 16);
canvas.height = 1440; //window.innerHeight - (16 + 16);
I rerender the image by reloading the browser. Maybe you find a better solution that makes the preserveDrawingBuffer work with the gui redraw.
//download img as png on canvas click
(function() {
var canvas = document.querySelector("#render-canvas");
var uri;
canvas.onclick = function(evt) {
evt.preventDefault();
canvas.toBlob(function(blob) {
if(uri)
(window.URL||window.webkitURL).revokeObjectURL(uri);
uri = (window.URL||window.webkitURL).createObjectURL(blob);
var a = document.createElement('a');
a.href = uri;
a.download="stars.png";
document.body.appendChild(a);
a.onclick = function(evt) { this.parentNode.removeChild(this); }
a.click();
});
}
})();
Metadata
Metadata
Assignees
Labels
No labels