我查遍了整个互联网,但找不到任何地方可以向我解释 import
在处理 JS 中的工作原理。
我该如何做这样的事情?
<小时/> block.pdevoid drawRect() {
fill(255, 0, 0);
rect(30, 30, width - 60, height - 60);
}
<小时/>
core.pde
import block;
void setup() {
size(800, 500);
background(240);
frameRate(120);
}
void draw() {
background(240);
drawRect();
}
<小时/>
那么您将如何使用import
?您可以导入自己制作的文件吗?
最佳答案
您不需要导入任何内容。
这个:
Create a web page that includes Processing.js as well as a
<canvas>
with info about where to get your sketch file (you can specify multiple *.pde files, separating them with spaces): 1<script src="processing-1.3.6.min.js"></script>
2<canvas data-processing-sources="hello-web.pde"></canvas>
Load your web page, and it will parse, translate, and run your sketch in the browser.
来自here ,建议您应该能够执行以下操作:
<canvas data-processing-sources="core.pde block.pde"></canvas>
然后您应该能够在不使用任何导入语句的情况下调用drawRect(),就像在具有多个pdes的标准草图中一样。
关于javascript - 导入处理JS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27887878/