另一个与处理相关的问题。有人可以向我解释PVector在Processing中的工作原理吗?更具体地说,我正在寻找一种加载自定义矢量形状(.svg)的方法,但我的处理知识再次受到限制。到目前为止,我理解这样的事情可能:
PVector vector1
vector1 = new PVector((width),(height));
现在,是否可以加载自定义矢量形状?或者我是否误解了与Processing有关的向量?如果有人可以向我提供有关此事的一些信息,我将不胜感激。
非常感谢。
答案 0 :(得分:1)
PVector
类不包含矢量形状。它包含mathematical vector(换句话说,2D或3D点)。
您正在寻找the PShape
class,特别是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);
}