参考 endShape()

endShape()

开始向自定义形状添加顶点。

beginShape()endShape() 函数允许在 2D 或 3D 中创建自定义形状。 beginShape() 开始添加顶点到一个自定义形状,而 endShape() 则停止添加。

第一个参数 mode 是可选的。默认情况下,形状的第一个和最后一个顶点不相连。如果传递常量 CLOSE, 如 endShape(CLOSE) 那么第一个和最后一个顶点将会连接起来。

第二个参数 count 也是可选的。 在 WebGL 模式下,如果要绘制许多相同形状的副本,更高效的方法是使用 instancing 的技术。 count 参数告诉 WebGL 模式要绘制多少个副本。例如,在绘制自定义形状后调用 endShape(CLOSE, 400) 会使绘制 400 个副本变得高效。 此功能需要 writing a custom shader

调用 beginShape() 后,可以通过调用 vertex()bezierVertex()quadraticVertex(),和/或 curveVertex() 来构建形状。调用 endShape() 将停止向形状添加顶点。每个形状都将用当前的描边颜色勾勒出轮廓,并填充当前的填充颜色。

一些变换图形的函数,如 translate()rotate(),和 scale()beginShape()endShape() 之间不起作用。在 beginShape()endShape() 之间也不能使用其他形状,比如 ellipse()rect()

示例

语法

endShape([mode], [count])

参数

mode

use CLOSE to close the shape

count

number of times you want to draw/instance the shape (for WebGL mode).

Notice any errors or typos? Please let us know. Please feel free to edit src/core/shape/vertex.js and open a pull request!

相关参考