Closed leiz-me closed 3 years ago
This is how I did it (I added a ref in the SketchCanvas):
<SketchCanvas
ref="sketchRef"
style={{ flex: 1 }}
strokeColor={'black'}
strokeWidth={strokeWidthMain}
/>
<TouchableOpacity style={styles.customButton} onPress={() => { this.refs.sketchRef.clear() }}>
<Text>Clear</Text>
</TouchableOpacity>
@jamesnogra you are not understanding what i asked.
I mean clear the localSourceImage, since I found that if you set the localSourceImage, this way the sketch canvas changed its background to localSourceImage, then reset the localSourceImage to null, at this moment, sketch canvas DID NOT refresh its background image.
What you did is to clear the paths on the canvas, that's totally a different thing.
Thanks anyway.
@leiz-me this seems to be a bug in the library, the background image doesn't change to blank when setting null. But there's a way around to this which I have used, You can use a Plain Transparent Image as the background and set the transparent image as the background when you want to clear the screen.
@leiz-me this seems to be a bug in the library, the background image doesn't change to blank when setting null. But there's a way around to this which I have used, You can use a Plain Transparent Image as the background and set the transparent image as the background when you want to clear the screen.
Yes, that would be a good choice under the circumstances.
but the points will be always related to the transparent image and on the required image
I have a button called 'clear background image'. When I click this button, I want to remove the canvas' background image. How can I make it happen?