react-native - 如何在 React Native Expo 中实现 Processingview?
问题描述
这里我在 Expo App 中实现了 ProcessingView。但我收到此错误“检查 . 的渲染方法ProcessingView
”。我无法找到解决方案。如果有人有想法,请指导我。在这里我还附上了屏幕的图像
import React from 'react';
import { ProcessingView } from 'expo-processing';
export default class App extends React.Component {
render() {
return (
<ProcessingView style={{ flex: 1 }} sketch={this._sketch} />
);
}
_sketch = (p) => {
p.setup = () => {
p.strokeWeight(7);
}
const harom = (ax, ay, bx, by, level, ratio) => {
if (level <= 0) {
return;
}
const vx = bx - ax;
const vy = by - ay;
const nx = p.cos(p.PI / 3) * vx - p.sin(p.PI / 3) * vy;
const ny = p.sin(p.PI / 3) * vx + p.cos(p.PI / 3) * vy;
const cx = ax + nx;
const cy = ay + ny;
p.line(ax, ay, bx, by);
p.line(ax, ay, cx, cy);
p.line(cx, cy, bx, by);
harom(
ax * ratio + cx * (1 - ratio),
ay * ratio + cy * (1 - ratio),
ax * (1 - ratio) + bx * ratio,
ay * (1 - ratio) + by * ratio,
level - 1,
ratio);
}
p.draw = () => {
p.background(240);
harom(
p.width - 142, p.height - 142, 142, p.height - 142, 6,
(p.sin(0.0005 * Date.now() % (2 * p.PI)) + 1) / 2);
}
}
}
解决方案
推荐阅读
- r - RSQLite 警告:“SQL 变量太多”
- javascript - Bootstrap nav-link class is not working in Chrome, but works in Firefox, navigates to corresponding section
- node.js - Mongoose userModel 未定义
- c++ - 尝试使用 Assimp GLM 从 MD5 文件加载 OpenGL 中的动画
- adobe - Scene7 URL parameters
- one-to-one - Proving a function isn't 1 to 1
- r - 在 R 中抓取标签链接
- javascript - Javascript:如何在不创建循环依赖项的情况下重用创建子实例的方法
- php - 无法将数据从用户表单发送到 PHP 中的数据库
- javascript - 如何构建我的网站,以便在输入新 URL 时通过 AJAX 加载新内容?