Skip to content

Commit 12250ef

Browse files
committed
Fixed a image rendering bug
1 parent 72ef95e commit 12250ef

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ImageTint.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ImageTint extends React.Component {
1717
tint: PropTypes.oneOfType([
1818
PropTypes.arrayOf(PropTypes.number),
1919
PropTypes.string,
20-
PropTypes.objectOf(PropTypes.number)
20+
PropTypes.object
2121
]),
2222
src: PropTypes.string
2323
}
@@ -76,20 +76,24 @@ class ImageTint extends React.Component {
7676
img = processing.loadImage(src)
7777
}
7878

79-
// Called once
79+
// Called once when the image is loaded
8080
setup = () => {
8181
processing.createCanvas(width, height, getRendererType(renderer))
8282
processing.image(img, 0, 0)
83+
}
84+
85+
// Draw the image (apply the filters)
86+
draw = () => {
8387
this.applyTintValues(processing, tint)
8488
processing.image(img, 0, 0)
8589
}
8690

87-
// Start Processing
88-
dispatch([preload, setup])
91+
// Start Processing (dispatch all the processing functions)
92+
dispatch([preload, setup, draw])
8993
}
9094

9195
// Returns the new canvas
92-
getCanvas = () => new p5(this.renderSketch, this.wrapper).canvas
96+
getCanvas = () => new p5(this.renderSketch, this.wrapper)
9397

9498
componentDidMount = () => this.getCanvas()
9599

0 commit comments

Comments
 (0)