将草绘的线保存到LocalStorage

时间:2019-07-10 12:08:40

标签: react-native expo

对不起,我在这里发布了

我想保存我在画布上绘制的每一行的信息(保存操作将称为onChange) 这样我就可以检索这些数据并再次将其绘制在画布上,以防用户更改屏幕或其他内容。

我正在使用expo-pixi绘制图像并在其上绘制草图

onChangeAsync = async (param) => {
// here i want on change code i get the line informantion and store it

}
onLayout = async ({
        nativeEvent: {
            layout: { width, height },
        },
    }) => {
        this.setState({
            layoutWidth: width,
            layoutHeight: height,
        })
        this.onReady();
    }
onReady = async () => {
        const { layoutWidth, layoutHeight, points } = this.state;
        this.sketch.graphics = new PIXI.Graphics();

        if (this.sketch.stage) {

            if (layoutWidth && layoutHeight) {
                const background = await PIXI.Sprite.fromExpoAsync(this.props.image);
                background.width = layoutWidth * scaleR;
                background.height = layoutHeight * scaleR;

                this.sketch.stage.addChild(background);
                this.sketch.renderer._update();
            }
        }
    };

// The sketch component is pretty much as the example which comes with the lib
<Sketch
 ref={ref => (this.sketch = ref)}
 style={styles.sketch}
 strokeColor={this.state.strokeColor}
 strokeWidth={this.state.strokeWidth}
 strokeAlpha={1}
 onChange={this.onChangeAsync}
 onReady={this.onReady}
/>

有人有任何线索吗?我有点绝望

谢谢

0 个答案:

没有答案