Processing, 类PShape中的setVertex()用法介绍。
用法
sh.setVertex(index, x, y)sh.setVertex(index, x, y, z)sh.setVertex(index, vec)
参数
sh(PShape)任何 PShape 类型的变量index(int)顶点的位置x(float)顶点的 x 值y(float)顶点的 y 值z(float)顶点的 z 值vec(PVector)用于定义 x、y、z 坐标的 PVector
返回
void
说明
setVertex() 方法定义位于由index 参数定义的位置的顶点坐标。此方法在如上例所示创建形状时有效,但在明确定义形状时(例如 createShape(RECT, 20, 20, 80, 80) .
例子
PShape s;
void setup() {
size(100, 100);
s = createShape();
s.beginShape();
s.vertex(0, 0);
s.vertex(60, 0);
s.vertex(60, 60);
s.vertex(0, 60);
s.endShape(CLOSE);
}
void draw() {
translate(20, 20);
for (int i = 0; i < s.getVertexCount(); i++) {
PVector v = s.getVertex(i);
v.x += random(-1, 1);
v.y += random(-1, 1);
s.setVertex(i, v);
}
shape(s);
}
相关用法
- Processing PShape.setVisible()用法及代码示例
- Processing PShape.setStroke()用法及代码示例
- Processing PShape.setFill()用法及代码示例
- Processing PShape.scale()用法及代码示例
- Processing PShape.enableStyle()用法及代码示例
- Processing PShape.addChild()用法及代码示例
- Processing PShape.isVisible()用法及代码示例
- Processing PShape.getChildCount()用法及代码示例
- Processing PShape.getVertex()用法及代码示例
- Processing PShape.resetMatrix()用法及代码示例
- Processing PShape.rotateX()用法及代码示例
- Processing PShape.getChild()用法及代码示例
- Processing PShape.rotateY()用法及代码示例
- Processing PShape.beginContour()用法及代码示例
- Processing PShape.beginShape()用法及代码示例
- Processing PShape.endShape()用法及代码示例
- Processing PShape.getVertexCount()用法及代码示例
- Processing PShape.rotate()用法及代码示例
- Processing PShape.endContour()用法及代码示例
- Processing PShape.disableStyle()用法及代码示例
- Processing PShape.translate()用法及代码示例
- Processing PShape用法及代码示例
- Processing PShader用法及代码示例
- Processing Pulse用法及代码示例
- Processing PVector.set()用法及代码示例
注:本文由纯净天空筛选整理自processing.org大神的英文原创作品 PShape.setVertex()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
