gpt4 book ai didi

nullpointerexception - PShape 2.08 使用 createShape 抛出 NullPointerException

转载 作者:行者123 更新时间:2023-12-02 01:11:53 28 4
gpt4 key购买 nike

我在 mac 上使用 Processing 2.08。我正在尝试使用文档中给出的 createShape 函数创建 PShape。

PShape s;

void setup(){
size(500,500);
s = createShape();
s.beginShape(QUADS);
s.fill(0);
s.vertex(100,100);
s.vertex(100,300);
s.vertex(300,300);
s.vertex(300,100);
s.endShape();
}

void draw(){
shape(s);
}

但是这个程序抛出 NullPointerException。在 Processing.org 论坛上查找时,我发现一个线程说新的处理库对此有问题。

引用:https://forum.processing.org/topic/changes-to-pshape-in-2-08

我如何使它起作用?有什么解决方法吗?谢谢

最佳答案

来自文档:

Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) and OBJ shapes. Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. The PShape object contains a group of methods, linked below, that can operate on the shape data. OBJ files can only be opened using the P3D renderer.

您可以在此处找到引用:http://processing.org/reference/PShape.html

简而言之,目前,您必须先在别处创建形状才能使用 PShape。

您可以独立创建一个图像,将其保存在文件中,然后使用 PShape 加载它。这是一个 hack,但至少在他们想出更合适的修复之前,它可以使用 PShape。

关于nullpointerexception - PShape 2.08 使用 createShape 抛出 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16601675/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com