react-native - 在 LocalStorage 中保存草图线
问题描述
对不起,我把这个贴在这里
我想保存我在画布上绘制的每一行的信息(保存操作将被称为 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}
/>
有没有人有任何线索?我有点绝望
谢谢
解决方案
推荐阅读
- python - 只移动文件而不移动目录的麻烦
- r - data.table 根据唯一 ID 的第一行和最后一行生成具有间隔的序列
- leaflet - 有没有办法检查图标明显相交/重叠的标记?
- r - 我们如何将大型数据集从 Google BigQuery 导入 R?
- javascript - Express 除了发送 HTML 文件之外什么都不做
- javascript - 如何在 ReactJS 中添加/混合 Vanilla Javascript
- node.js - 在 Windows 上使用 npm run/yarn run 本地安装的可执行依赖项失败
- r - 从数据框中收集列和行中具有相同名称的值
- c# - 使用 VersionOne .Net SDK 建立/测试连接
- java - 为什么在 JBoss7.1.EAP 中加载 applicationContext 时出现 java.lang.NoSuchMethodError