gre / react-native-view-shot

Snapshot a React Native view and save it to an image
https://github.com/gre/react-native-view-shot-example
MIT License
2.64k stars 343 forks source link

(Web) Add backgroundColor to captureRef #483

Closed burakgormek closed 5 months ago

burakgormek commented 1 year ago

Html2canvas have backgroundColor option which is sets background color of captured image. Default value is "#FFFFFF" so if you capture image on web, there will be a white border on bottom. We need to add option to set html2canvas background. This pr does this.

I also set default value to null which is corresponds "transparent" on html2canvas side. This matches the native behavior better(iOS, Android).

Reproduce:

<View ref={viewRef} style={{ backgroundColor: "red", width: 50 }}>Test</View>

Before: image After { backgroundColor: "red" }: image

burakgormek commented 11 months ago

Maybe we can get color from the ref view