首页 > 文档 > beginShape()开始绘制图形
2017
08-01

beginShape()开始绘制图形

Name

beginShape()开始绘制图形

   

Examples

beginShape()开始绘制图形 - 第1张  | Processing编程艺术beginShape()开始绘制图形 - 第2张  | Processing编程艺术beginShape()开始绘制图形 - 第3张  | Processing编程艺术

beginShape();

vertex(30, 20);

vertex(85, 20);

vertex(85, 75);

vertex(30, 75);

endShape(CLOSE);

beginShape()开始绘制图形 - 第4张  | Processing编程艺术beginShape()开始绘制图形 - 第5张  | Processing编程艺术beginShape()开始绘制图形 - 第6张  | Processing编程艺术

beginShape(POINTS);

vertex(30, 20);

vertex(85, 20);

vertex(85, 75);

vertex(30, 75);

endShape();

beginShape()开始绘制图形 - 第7张  | Processing编程艺术beginShape()开始绘制图形 - 第8张  | Processing编程艺术beginShape()开始绘制图形 - 第9张  | Processing编程艺术

beginShape(LINES);

vertex(30, 20);

vertex(85, 20);

vertex(85, 75);

vertex(30, 75);

endShape();

beginShape()开始绘制图形 - 第10张  | Processing编程艺术beginShape()开始绘制图形 - 第11张  | Processing编程艺术beginShape()开始绘制图形 - 第12张  | Processing编程艺术

noFill();

beginShape();

vertex(30, 20);

vertex(85, 20);

vertex(85, 75);

vertex(30, 75);

endShape();

beginShape()开始绘制图形 - 第13张  | Processing编程艺术beginShape()开始绘制图形 - 第14张  | Processing编程艺术beginShape()开始绘制图形 - 第15张  | Processing编程艺术

noFill();

beginShape();

vertex(30, 20);

vertex(85, 20);

vertex(85, 75);

vertex(30, 75);

endShape(CLOSE);

beginShape()开始绘制图形 - 第16张  | Processing编程艺术beginShape()开始绘制图形 - 第17张  | Processing编程艺术beginShape()开始绘制图形 - 第18张  | Processing编程艺术

beginShape(TRIANGLES);

vertex(30, 75);

vertex(40, 20);

vertex(50, 75);

vertex(60, 20);

vertex(70, 75);

vertex(80, 20);

endShape();

beginShape()开始绘制图形 - 第19张  | Processing编程艺术beginShape()开始绘制图形 - 第20张  | Processing编程艺术beginShape()开始绘制图形 - 第21张  | Processing编程艺术

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()开始绘制图形 - 第22张  | Processing编程艺术beginShape()开始绘制图形 - 第23张  | Processing编程艺术beginShape()开始绘制图形 - 第24张  | Processing编程艺术

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()开始绘制图形 - 第25张  | Processing编程艺术beginShape()开始绘制图形 - 第26张  | Processing编程艺术beginShape()开始绘制图形 - 第27张  | Processing编程艺术

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()开始绘制图形 - 第28张  | Processing编程艺术beginShape()开始绘制图形 - 第29张  | Processing编程艺术beginShape()开始绘制图形 - 第30张  | Processing编程艺术

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()开始绘制图形 - 第31张  | Processing编程艺术beginShape()开始绘制图形 - 第32张  | Processing编程艺术beginShape()开始绘制图形 - 第33张  | Processing编程艺术

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_FANTRIANGLE_STRIP、四方形和 QUAD_STRIP。调用 beginShape () 函数后, 必须执行一系列顶点 () 命令。要停止绘制形状, 请调用 endShape ()。具有两个参数的顶点 () 函数指定2D 中的位置, 而顶点 () 函数具有三参数, 指定3D 中的位置。每个形状都将用当前描边颜色进行分级, 并用填充颜色填充。

 

翻译 ()、旋转 () 和缩放 () 等转换在 beginShape () 中不起作用。也不可能在 beginShape () 中使用其他形状, 如椭圆 () 或矩形 ()

 

P2D P3D 器允许在每个顶点的基础上更改笔画 () 和填充 (), 但默认呈现器不会。在使用任何渲染器的 beginShape ()/endShape () 块内, 无法更改 strokeWeight ()strokeCap () strokeJoin () 等设置。

Syntax

beginShape()

beginShape(kind)

Parameters

kind

int: Either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, or QUAD_STRIP

整数型:点,线,三角形,风扇组合式三角形,地带组合式三角形,矩形或者地带组合式矩形

Returns

void

Related

PShape
endShape()
vertex()
curveVertex()
bezierVertex()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。