处理:PVector 和加载自定义形状

Processing: PVector and loading custom shapes

另一个处理相关的问题。有人可以向我解释 PVector 在 Processing 中是如何工作的吗?更具体地说,我正在寻找一种加载自定义矢量形状 (.svg) 的方法,但我对 Processing 的了解还是太有限了。到目前为止,我明白这样的事情是可能的:

PVector vector1

vector1 = new PVector((width),(height));

现在,是否也可以加载自定义矢量形状?还是我误解了与处理相关的向量?如果有人能向我提供一些相关信息,我将不胜感激。

非常感谢。

PVector class 不保持矢量形状。它包含一个 mathematical vector(换句话说,一个 2D 或 3D 点)。

您正在寻找 the PShape class, specifically the loadShape() function,它允许您加载 .svg 文件。

PShape s;

void setup() {
  size(100, 100);
  // The file "bot.svg" must be in the data folder
  // of the current sketch to load successfully
  s = loadShape("bot.svg");
}

void draw() {
  shape(s, 10, 10, 80, 80);
}