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

Ability to accept <canvas /> element in fx.canvas and custom build ability #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@

def sources():
return [os.path.join(base, f) for base, folders, files in \
os.walk(input_path) for f in files if f.endswith('.js')]
os.walk(input_path) for f in files if 'include' in sys.argv and includes(os.path.join(base, f)) or 'include' not in sys.argv and f.endswith('.js')]

def includes(file):
if '/filters/' in file:
if 'common' in file:
return True
for name in sys.argv:
if name in file:
return True
return False
return True

def compile(sources):
return '\n'.join('// %s\n%s' % (path, open(path).read()) for path in sources)
Expand Down
50 changes: 25 additions & 25 deletions src/core/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ function wrap(func) {
};
}

exports.canvas = function() {
var canvas = document.createElement('canvas');
exports.canvas = function(canvas) {
canvas = canvas instanceof window.HTMLCanvasElement ? canvas : document.createElement('canvas');
try {
gl = canvas.getContext('experimental-webgl', { premultipliedAlpha: false });
} catch (e) {
Expand All @@ -156,29 +156,29 @@ exports.canvas = function() {
canvas.getPixelArray = wrap(getPixelArray);

// Filter methods
canvas.brightnessContrast = wrap(brightnessContrast);
canvas.hexagonalPixelate = wrap(hexagonalPixelate);
canvas.hueSaturation = wrap(hueSaturation);
canvas.colorHalftone = wrap(colorHalftone);
canvas.triangleBlur = wrap(triangleBlur);
canvas.unsharpMask = wrap(unsharpMask);
canvas.perspective = wrap(perspective);
canvas.matrixWarp = wrap(matrixWarp);
canvas.bulgePinch = wrap(bulgePinch);
canvas.tiltShift = wrap(tiltShift);
canvas.dotScreen = wrap(dotScreen);
canvas.edgeWork = wrap(edgeWork);
canvas.lensBlur = wrap(lensBlur);
canvas.zoomBlur = wrap(zoomBlur);
canvas.noise = wrap(noise);
canvas.denoise = wrap(denoise);
canvas.curves = wrap(curves);
canvas.swirl = wrap(swirl);
canvas.ink = wrap(ink);
canvas.vignette = wrap(vignette);
canvas.vibrance = wrap(vibrance);
canvas.sepia = wrap(sepia);
typeof brightnessContrast !== 'undefined' && (canvas.brightnessContrast = wrap(brightnessContrast));
typeof hexagonalPixelate !== 'undefined' && (canvas.hexagonalPixelate = wrap(hexagonalPixelate));
typeof hueSaturation !== 'undefined' && (canvas.hueSaturation = wrap(hueSaturation));
typeof colorHalftone !== 'undefined' && (canvas.colorHalftone = wrap(colorHalftone));
typeof triangleBlur !== 'undefined' && (canvas.triangleBlur = wrap(triangleBlur));
typeof unsharpMask !== 'undefined' && (canvas.unsharpMask = wrap(unsharpMask));
typeof perspective !== 'undefined' && (canvas.perspective = wrap(perspective));
typeof matrixWarp !== 'undefined' && (canvas.matrixWarp = wrap(matrixWarp));
typeof bulgePinch !== 'undefined' && (canvas.bulgePinch = wrap(bulgePinch));
typeof tiltShift !== 'undefined' && (canvas.tiltShift = wrap(tiltShift));
typeof dotScreen !== 'undefined' && (canvas.dotScreen = wrap(dotScreen));
typeof edgeWork !== 'undefined' && (canvas.edgeWork = wrap(edgeWork));
typeof lensBlur !== 'undefined' && (canvas.lensBlur = wrap(lensBlur));
typeof zoomBlur !== 'undefined' && (canvas.zoomBlur = wrap(zoomBlur));
typeof noise !== 'undefined' && (canvas.noise = wrap(noise));
typeof denoise !== 'undefined' && (canvas.denoise = wrap(denoise));
typeof curves !== 'undefined' && (canvas.curves = wrap(curves));
typeof swirl !== 'undefined' && (canvas.swirl = wrap(swirl));
typeof ink !== 'undefined' && (canvas.ink = wrap(ink));
typeof vignette !== 'undefined' && (canvas.vignette = wrap(vignette));
typeof vibrance !== 'undefined' && (canvas.vibrance = wrap(vibrance));
typeof sepia !== 'undefined' && (canvas.sepia = wrap(sepia));

return canvas;
};
exports.splineInterpolate = splineInterpolate;
typeof splineInterpolate !== 'undefined' && (exports.splineInterpolate = splineInterpolate);