首页 > 文档 > loadShape()加载形状
2017
07-12

loadShape()加载形状

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);

}

loadShape()加载形状 - 第1张  | Processing编程艺术

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.
将几何形状加载到一个类型为PShape的变量中。可以加载SVG和OBJ文件。要正确加载,文件必须位于当前路径下的data文件中。在大多数情况下,loadShape()应该在setup()中设置,因为在draw()中加载形状将会降低程序的运行速度。


Alternatively, the file maybe be loaded from anywhere on the local computer using an absolute path (something that starts with / on Unix and Linux, or a drive letter on Windows), or the filename parameter can be a URL for a file found on a network.
或者,使用绝对路径可以让文件从本地计算机的任何地方加载(路径是以Unix、Linux或Windows上的驱动器字母开始,比如C:\),或者文件名参数也可以是在网络上找到的文件的URL(网络路径)。


If the file is not available or an error occurs,
 null will be returned and an error message will be printed to the console. The error message does not halt the program, however the null value may cause a NullPointerException if your code does not check whether the value returned is null.

如果文件不可用或出现错误,将返回null,并将错误消息打印到控制台。错误消息不会停止程序,但是如果代码不检查返回的值是否为空,null值可能会导致出现NullPointerException提示。

Syntax

语法

loadShape(filename)

Parameters

参数

filename

String: name of file to load, can be .svg or .obj

字符串格式:文件名、绝对路径、网络路径

Returns

返回值

PShape


 



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。