Name |
beginShape()开始绘制图形 |
||
Examples |
beginShape(); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape(CLOSE);
beginShape(POINTS); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape();
beginShape(LINES); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape();
noFill(); beginShape(); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape();
noFill(); beginShape(); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape(CLOSE);
beginShape(TRIANGLES); vertex(30, 75); vertex(40, 20); vertex(50, 75); vertex(60, 20); vertex(70, 75); vertex(80, 20); endShape();
beginShape(TRIANGLE_STRIP); vertex(30, 75); vertex(40, 20); vertex(50, 75); vertex(60, 20); vertex(70, 75); vertex(80, 20); vertex(90, 75); endShape();
beginShape(TRIANGLE_FAN); vertex(57.5, 50); vertex(57.5, 15); vertex(92, 50); vertex(57.5, 85); vertex(22, 50); vertex(57.5, 15); endShape();
beginShape(QUADS); vertex(30, 20); vertex(30, 75); vertex(50, 75); vertex(50, 20); vertex(65, 20); vertex(65, 75); vertex(85, 75); vertex(85, 20); endShape();
beginShape(QUAD_STRIP); vertex(30, 20); vertex(30, 75); vertex(50, 20); vertex(50, 75); vertex(65, 20); vertex(65, 75); vertex(85, 20); vertex(85, 75); endShape();
beginShape(); vertex(20, 20); vertex(40, 20); vertex(40, 40); vertex(60, 40); vertex(60, 60); vertex(20, 60); endShape(CLOSE); |
||
Description |
Using the beginShape() and endShape() functions allow creating more complex forms. beginShape() begins recording vertices for a shape and endShape() stops recording. The value of the kind parameter tells it which types of shapes to create from the provided vertices. With no mode specified, the shape can be any irregular polygon. The parameters available for beginShape() are POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRIP. After calling the beginShape() function, a series of vertex() commands must follow. To stop drawing the shape, call endShape(). The vertex() function with two parameters specifies a position in 2D and the vertex() function with three parameters specifies a position in 3D. Each shape will be outlined with the current stroke color and filled with the fill color. Transformations such as translate(), rotate(), and scale() do not work within beginShape(). It is also not possible to use other shapes, such as ellipse() or rect() within beginShape(). The P2D and P3D renderers allow stroke() and fill() to be altered on a per-vertex basis, but the default renderer does not. Settings such as strokeWeight(), strokeCap(), and strokeJoin()cannot be changed while inside a beginShape()/endShape() block with any renderer. 使用 beginShape () 和 endShape () 函数可以创建更复杂的窗体。beginShape () 开始记录形状的顶点, endShape () 停止录制。该类型参数的值告诉它从提供的顶点创建哪些类型的形状。没有指定模式, 形状可以是任何不规则的多边形。可用于 beginShape () 的参数是点、线、三角形、TRIANGLE_FAN、TRIANGLE_STRIP、四方形和 QUAD_STRIP。调用 beginShape () 函数后, 必须执行一系列顶点 () 命令。要停止绘制形状, 请调用 endShape ()。具有两个参数的顶点 () 函数指定2D 中的位置, 而顶点 () 函数具有三参数, 指定3D 中的位置。每个形状都将用当前描边颜色进行分级, 并用填充颜色填充。
翻译 ()、旋转 () 和缩放 () 等转换在 beginShape () 中不起作用。也不可能在 beginShape () 中使用其他形状, 如椭圆 () 或矩形 ()。
P2D 和 P3D 器允许在每个顶点的基础上更改笔画 () 和填充 (), 但默认呈现器不会。在使用任何渲染器的 beginShape ()/endShape () 块内, 无法更改 strokeWeight ()、strokeCap () 和 strokeJoin () 等设置。 |
||
Syntax |
beginShape() beginShape(kind) |
||
Parameters |
|
||
Returns |
void |
||
Related |
PShape |
- 本文固定链接: http://iprocessing.cn/2017/08/01/beginshape开始绘制图形/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表