From ceded0e14847e061c9490e1bbe5d07a4cf8ed6bd Mon Sep 17 00:00:00 2001 From: Li Zheng Date: Sun, 1 Jan 2023 15:48:17 +0800 Subject: [PATCH] react -> react-native: `Zdog and Tests` step5 document.createElement('canvas') with offscreenCanvas works well --- app/components/ZdogAndTests.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/components/ZdogAndTests.js b/app/components/ZdogAndTests.js index 31ddc7c..8444134 100644 --- a/app/components/ZdogAndTests.js +++ b/app/components/ZdogAndTests.js @@ -396,6 +396,7 @@ export default class ZdogAndTests extends Component { this.canvas = null; this.state = { debugInfo: 'Click me to draw some on canvas', + hasOc1: false, }; // only useful on Android, because it's always true on iOS @@ -499,6 +500,23 @@ export default class ZdogAndTests extends Component { {this.state.debugInfo} + {Platform.OS !== 'web' && ( + this.setState({hasOc1: true})} // it's better to setState some as describe in https://github.com/flyskywhy/react-native-gcanvas/blob/master/README.MD + devicePixelRatio={1} // should not 1 < devicePixelRatio < 2 as float to avoid pixel offset flaw when GetImageData with PixelsSampler in @flyskywhy/react-native-gcanvas/core/src/support/GLUtil.cpp + isGestureResponsible={false} // who will need gesture with offscreen canvas? + /> + )} + {Platform.OS === 'web' ? ( - ) : ( + ) : (this.state.hasOc1 && ( - )} + ))} Click me runTests react-native-browser-polyfill