Last active
December 3, 2017 21:31
-
-
Save mathisonian/3c50840e9166e6c53506db6182b6b10c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const React = require('react'); | |
const D3Component = require('idyll-d3-component'); | |
const d3 = require('d3'); | |
class FilterComponent extends D3Component { | |
initialize(node, props) { | |
// instead of adding an svg, add a canvas | |
var canvas = d3.select(node).append("canvas") | |
.attr("width", ...) | |
.attr("height", ...); | |
this.context = canvas.node().getContext("2d"); | |
} | |
update(props) { | |
// check if the "filter" prop changed | |
if (props.filter !=== this.props.filter) { | |
switch(props.filter) { | |
case 'horizontal_sobel': | |
// you can use | |
// this.context here to | |
// update the canvas | |
break; | |
case 'vertical_sobel': | |
break; | |
case 'sobel': | |
break; | |
case 'laplacian': | |
break; | |
case 'canny': | |
break; | |
} | |
} | |
} | |
} | |
module.exports = FilterComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment