loadShape()
Name 名称 |
loadShape() 加载形状 |
||
Examples 例子 |
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); }
PShape s;
void setup() { size(100, 100, P3D); // The file “bot.obj” must be in the data folder // of the current sketch to load successfully s = loadShape(“bot.obj”); }
void draw() { background(204); translate(width/2, height/2); shape(s, 0, 0); } |
||
Description 描述 |
Loads geometry into a variable of type PShape. SVG and OBJ files may be loaded. To load correctly, the file must be located in the data directory of the current sketch. In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch.
如果文件不可用或出现错误,将返回null,并将错误消息打印到控制台。错误消息不会停止程序,但是如果代码不检查返回的值是否为空,null值可能会导致出现NullPointerException提示。 |
||
Syntax 语法 |
loadShape(filename) |
||
Parameters 参数 |
|
||
Returns 返回值 |
PShape |
- 本文固定链接: http://iprocessing.cn/2017/07/12/loadshape加载形状/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表