Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add export canvas method (current rendering result) #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/core/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ function getPixelArray() {
return array;
}

function copyCanvas() {
var w = this.width;
var h = this.height;
var c = document.createElement('canvas');
c.width = w;
c.height = h;
var ctx = c.getContext('2d');
this.update();
ctx.drawImage( this, 0, 0, w, h );
return c;
}

function wrap(func) {
return function() {
// Make sure that we're using the correct global WebGL context
Expand Down Expand Up @@ -154,6 +166,7 @@ exports.canvas = function() {
canvas.replace = wrap(replace);
canvas.contents = wrap(contents);
canvas.getPixelArray = wrap(getPixelArray);
canvas.copyCanvas = wrap(copyCanvas);

// Filter methods
canvas.brightnessContrast = wrap(brightnessContrast);
Expand Down