在ubuntu中运行带有vs代码/终端扩展的Sketch处理会引发错误



我想运行一个处理草图,而不是在ubuntu 20.04下使用处理IDE(我想使用vs代码及其扩展,但也可以从命令行运行它(。我在/opt/processing-4.0.1/processing-java下安装了processing-java

然后我想运行这个我从网站上抓取的示例草图:

/**
* Array 2D. 
* 
* Demonstrates the syntax for creating a two-dimensional (2D) array.
* Values in a 2D array are accessed through two index values.  
* 2D arrays are useful for storing images. In this example, each dot 
* is colored in relation to its distance from the center of the image. 
*/
float[][] distances;
float maxDistance;
int spacer;
void setup() {
size(640, 360);
maxDistance = dist(width/2, height/2, width, height);
distances = new float[width][height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float distance = dist(width/2, height/2, x, y);
distances[x][y] = distance/maxDistance * 255;
}
}
spacer = 10;
strokeWeight(6);
noLoop();  // Run once and stop
}
void draw() {
background(0);
// This embedded loop skips over values in the arrays based on
// the spacer variable, so there are more values in the array
// than are drawn here. Change the value of the spacer variable
// to change the density of the points
for (int y = 0; y < height; y += spacer) {
for (int x = 0; x < width; x += spacer) {
stroke(distances[x][y]);
point(x + spacer/2, y + spacer/2);
}
}
}

为此,我使用命令:

/opt/processing-4.0.1/processing-java --sketch=<name_of_folter_with_sketch> --output=~/Desktop --force --run

然而,我收到了这个错误(当我试图从vs代码扩展运行草图时,我也收到了同样的错误(:

/opt/processing-4.0.1/processing-java --sketch=2dPerlinNoise --output=~/Desktop   --build
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at processing.app.Sketch.getMainName(Sketch.java:1699)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:144)
at processing.mode.java.JavaBuild.build(JavaBuild.java:110)
at processing.mode.java.Commander.<init>(Commander.java:233)
at processing.mode.java.Commander.main(Commander.java:417)

在Processing IDE中,它运行时没有问题。。。你知道我可能做错了什么吗?

任意ide

对我来说,将我的项目重命名为不带的名称很有帮助

  • 空格
  • 任何特殊字符
  • 数字

请确保更改目录的名称,因为它必须与.pde文件相同。

最新更新