beginShape()

本参考资料用于Processing 3.0+。 如果你使用的是前一版本,请在使用软件帮助菜单内的参考资料。. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

名称

beginShape()

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

描述 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() beginShape(kind)
参数
kind int: Either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, or QUAD_STRIP
返回值 void
相关 PShape
endShape()
vertex()
curveVertex()
bezierVertex()

Updated on October 2, 2018 05:02:08pm EDT

beginShape()