@@ -17,7 +17,7 @@ class ImageTint extends React.Component {
17
17
tint : PropTypes . oneOfType ( [
18
18
PropTypes . arrayOf ( PropTypes . number ) ,
19
19
PropTypes . string ,
20
- PropTypes . objectOf ( PropTypes . number )
20
+ PropTypes . object
21
21
] ) ,
22
22
src : PropTypes . string
23
23
}
@@ -76,20 +76,24 @@ class ImageTint extends React.Component {
76
76
img = processing . loadImage ( src )
77
77
}
78
78
79
- // Called once
79
+ // Called once when the image is loaded
80
80
setup = ( ) => {
81
81
processing . createCanvas ( width , height , getRendererType ( renderer ) )
82
82
processing . image ( img , 0 , 0 )
83
+ }
84
+
85
+ // Draw the image (apply the filters)
86
+ draw = ( ) => {
83
87
this . applyTintValues ( processing , tint )
84
88
processing . image ( img , 0 , 0 )
85
89
}
86
90
87
- // Start Processing
88
- dispatch ( [ preload , setup ] )
91
+ // Start Processing (dispatch all the processing functions)
92
+ dispatch ( [ preload , setup , draw ] )
89
93
}
90
94
91
95
// Returns the new canvas
92
- getCanvas = ( ) => new p5 ( this . renderSketch , this . wrapper ) . canvas
96
+ getCanvas = ( ) => new p5 ( this . renderSketch , this . wrapper )
93
97
94
98
componentDidMount = ( ) => this . getCanvas ( )
95
99
0 commit comments