我当时在制作一部动画。然后,我有一个关于密码的问题。通常情况下,我的代码更长。然而,我做了一个简单的代码,它也可以用于初学者。我的示例代码:
void setup() {
size(250, 250);
}
void draw() {
background(102);
translate(100, 100);
beginShape();
vertex(0,0);
vertex(-50, 50);
vertex(0, 100);
endShape();
}
我必须使用三个顶点,我想要纹理的形状,如在texture()
。怎么做呢?
发布于 2020-06-20 11:20:28
为了将图像作为纹理放置在形状上:
Shape.
texture()
函数。
(img.width, img.height)
.
,(0, 0)
,(0, img.height)
PImage img;
void setup() {
size(250, 250, P2D);
img = loadImage("rectangular_image.jpg");
textureMode(IMAGE);
textureWrap(CLAMP);
}
void draw() {
background(102);
translate(100, 100);
noStroke();
beginShape();
texture(img);
vertex(0, 0, 0, 0);
vertex(-50, 50, 0, img.height);
vertex(0, 100, img.width, img.height);
endShape();
}
https://stackoverflow.com/questions/62489541
复制相似问题