MCPcopy
hub / github.com/processing/p5.js / _addCap

Method _addCap

src/webgl/p5.Geometry.js:1560–1572  ·  view source on GitHub ↗

* Adds the vertices and vertex attributes for two triangles representing the * stroke cap of a line. A fragment shader is responsible for displaying the * appropriate cap style within the rectangle they make. * * The lineSides buffer will include the following values for the points on

(point, tangent, color)

Source from the content-addressed store, hash-verified

1558 * @chainable
1559 */
1560 _addCap(point, tangent, color) {
1561 const ptArray = point.array();
1562 const tanInArray = tangent.array();
1563 const tanOutArray = [0, 0, 0];
1564 for (let i = 0; i < 6; i++) {
1565 this.lineVertices.push(...ptArray);
1566 this.lineTangentsIn.push(...tanInArray);
1567 this.lineTangentsOut.push(...tanOutArray);
1568 this.lineVertexColors.push(...color);
1569 }
1570 this.lineSides.push(-1, 2, -2, 1, 2, -1);
1571 return this;
1572 }
1573
1574 /**
1575 * Adds the vertices and vertex attributes for four triangles representing a

Callers 1

_edgesToVerticesMethod · 0.95

Calls 2

arrayMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected