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

Function customShapes

src/shape/custom_shapes.js:1541–3034  ·  view source on GitHub ↗
(p5, fn)

Source from the content-addressed store, hash-verified

1539}
1540
1541function customShapes(p5, fn) {
1542 // ---- GENERAL CLASSES ----
1543
1544 /**
1545 * @private
1546 * A class to describe a custom shape made with `beginShape()`/`endShape()`.
1547 *
1548 * Every `Shape` has a `kind`. The kind takes any value that
1549 * can be passed to <a href="#/p5/beginShape">beginShape()</a>:
1550 *
1551 * - `PATH`
1552 * - `POINTS`
1553 * - `LINES`
1554 * - `TRIANGLES`
1555 * - `QUADS`
1556 * - `TRIANGLE_FAN`
1557 * - `TRIANGLE_STRIP`
1558 * - `QUAD_STRIP`
1559 *
1560 * A `Shape` of any kind consists of `contours`, which can be thought of as
1561 * subshapes (shapes inside another shape). Each `contour` is built from
1562 * basic shapes called primitives, and each primitive consists of one or more vertices.
1563 *
1564 * For example, a square can be made from a single path contour with four line-segment
1565 * primitives. Each line segment contains a vertex that indicates its endpoint. A square
1566 * with a circular hole in it contains the circle in a separate contour.
1567 *
1568 * By default, each vertex only has a position, but a shape's vertices may have other
1569 * properties such as texture coordinates, a normal vector, a fill color, and a stroke color.
1570 * The properties every vertex should have may be customized by passing `vertexProperties` to
1571 * `createShape()`.
1572 *
1573 * Once a shape is created and given a name like `myShape`, it can be built up with
1574 * methods such as `myShape.beginShape()`, `myShape.vertex()`, and `myShape.endShape()`.
1575 *
1576 * Vertex functions such as `vertex()` or `bezierVertex()` are used to set the `position`
1577 * property of vertices, as well as the `textureCoordinates` property if applicable. Those
1578 * properties only apply to a single vertex.
1579 *
1580 * If `vertexProperties` includes other properties, they are each set by a method of the
1581 * same name. For example, if vertices in `myShape` have a `fill`, then that is set with
1582 * `myShape.fill()`. In the same way that a <a href="#/p5/fill">fill()</a> may be applied
1583 * to one or more shapes, `myShape.fill()` may be applied to one or more vertices.
1584 *
1585 * @class p5.Shape
1586 * @param {Object} [vertexProperties={position: createVector(0, 0)}] vertex properties and their initial values.
1587 */
1588
1589 p5.Shape = Shape;
1590
1591 /**
1592 * @private
1593 * A class to describe a contour made with `beginContour()`/`endContour()`.
1594 *
1595 * Contours may be thought of as shapes inside of other shapes.
1596 * For example, a contour may be used to create a hole in a shape that is created
1597 * with <a href="#/p5/beginShape">beginShape()</a>/<a href="#/p5/endShape">endShape()</a>.
1598 * Multiple contours may be included inside a single shape.

Callers 2

graphicsFunction · 0.85
custom_shapes.jsFile · 0.85

Calls 7

bezierOrderMethod · 0.45
splineVertexMethod · 0.45
splinePropertyMethod · 0.45
splinePropertiesMethod · 0.45
vertexMethod · 0.45
beginContourMethod · 0.45
endContourMethod · 0.45

Tested by

no test coverage detected