导入处理JS?
Import in Processing JS?
我在整个互联网上都看过了,但找不到任何地方向我解释 import
如何在 Processing JS 中工作。
我该怎么做?
block.pde
void 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 的标准草图中一样。
我在整个互联网上都看过了,但找不到任何地方向我解释 import
如何在 Processing JS 中工作。
我该怎么做?
block.pde
void 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 的标准草图中一样。