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

Function attributes

src/shape/attributes.js:9–570  ·  view source on GitHub ↗
(p5, fn)

Source from the content-addressed store, hash-verified

7import * as constants from '../core/constants';
8
9function attributes(p5, fn){
10 /**
11 * Changes where ellipses, circles, and arcs are drawn.
12 *
13 * By default, the first two parameters of
14 * <a href="#/p5/ellipse">ellipse()</a>, <a href="#/p5/circle">circle()</a>,
15 * and <a href="#/p5/arc">arc()</a>
16 * are the x- and y-coordinates of the shape's center. The next parameters set
17 * the shape's width and height. This is the same as calling
18 * `ellipseMode(CENTER)`.
19 *
20 * `ellipseMode(RADIUS)` also uses the first two parameters to set the x- and
21 * y-coordinates of the shape's center. The next parameters are half of the
22 * shapes's width and height. Calling `ellipse(0, 0, 10, 15)` draws a shape
23 * with a width of 20 and height of 30.
24 *
25 * `ellipseMode(CORNER)` uses the first two parameters as the upper-left
26 * corner of the shape. The next parameters are its width and height.
27 *
28 * `ellipseMode(CORNERS)` uses the first two parameters as the location of one
29 * corner of the ellipse's bounding box. The next parameters are the location
30 * of the opposite corner.
31 *
32 * The argument passed to `ellipseMode()` must be written in ALL CAPS because
33 * the constants `CENTER`, `RADIUS`, `CORNER`, and `CORNERS` are defined this
34 * way. JavaScript is a case-sensitive language.
35 *
36 * Calling `ellipseMode()` without an argument returns the current ellipseMode, either `CENTER`, `RADIUS`, `CORNER`, or `CORNERS`.
37 *
38 * @method ellipseMode
39 * @param {(CENTER|RADIUS|CORNER|CORNERS)} mode either CENTER, RADIUS, CORNER, or CORNERS
40 * @chainable
41 *
42 * @example
43 * function setup() {
44 * createCanvas(100, 100);
45 *
46 * background(200);
47 *
48 * // White ellipse.
49 * ellipseMode(RADIUS);
50 * fill(255);
51 * ellipse(50, 50, 30, 30);
52 *
53 * // Gray ellipse.
54 * ellipseMode(CENTER);
55 * fill(100);
56 * ellipse(50, 50, 30, 30);
57 *
58 * describe('A white circle with a gray circle at its center. Both circles have black outlines.');
59 * }
60 *
61 * @example
62 * function setup() {
63 * createCanvas(100, 100);
64 *
65 * background(200);
66 *

Callers 3

attributes.jsFile · 0.85
graphicsFunction · 0.85
attributes.jsFile · 0.85

Calls 4

setValueMethod · 0.45
strokeCapMethod · 0.45
strokeJoinMethod · 0.45
strokeWeightMethod · 0.45

Tested by

no test coverage detected