diff --git a/src/math/noise.js b/src/math/noise.js index 2752115494..fcc26a42d8 100644 --- a/src/math/noise.js +++ b/src/math/noise.js @@ -65,13 +65,7 @@ function noise(p5, fn){ * three dimensions. These dimensions can be thought of as space, as in * `noise(x, y, z)`, or space and time, as in `noise(x, y, t)`. * - * @method noise - * @param {Number} x x-coordinate in noise space. - * @param {Number} [y] y-coordinate in noise space. - * @param {Number} [z] z-coordinate in noise space. - * @return {Number} Perlin noise value at specified coordinates. - * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -89,8 +83,9 @@ function noise(p5, fn){ * strokeWeight(5); * point(x, y); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -115,8 +110,9 @@ function noise(p5, fn){ * strokeWeight(5); * point(x, y); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -138,8 +134,9 @@ function noise(p5, fn){ * // Draw the line. * line(x, 0, x, y); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -166,8 +163,9 @@ function noise(p5, fn){ * line(x, 0, x, y); * } * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -196,8 +194,9 @@ function noise(p5, fn){ * * describe('A gray cloudy pattern.'); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -227,10 +226,11 @@ function noise(p5, fn){ * } * } * } + * ``` * * `noise()` can also be used in shaders with p5.strands, where it returns - * values in the range 0 to 1. The following example uses `noise()` to create - * a cloud-like texture effect in a filter shader. + * values in the range 0 to 1. The example below uses `noise()` inside a + * filter shader to create a cloud-like texture effect: * * ```js example * let myFilter; @@ -257,6 +257,12 @@ function noise(p5, fn){ * filter(myFilter); * } * ``` + * + * @method noise + * @param {Number} x x-coordinate in noise space. + * @param {Number} [y] y-coordinate in noise space. + * @param {Number} [z] z-coordinate in noise space. + * @return {Number} Perlin noise value at specified coordinates. */ fn.noise = function(x, y = 0, z = 0) { if (perlin == null) { @@ -501,4 +507,4 @@ export default noise; if(typeof p5 !== 'undefined'){ noise(p5, p5.prototype); -} +} \ No newline at end of file diff --git a/src/math/random.js b/src/math/random.js index f6bc21eb3d..717c6bccc1 100644 --- a/src/math/random.js +++ b/src/math/random.js @@ -105,12 +105,7 @@ function random(p5, fn){ * For example, calling `random(-5, 10.2)` returns values from -5 up to but * not including 10.2. * - * @method random - * @param {Number} [min] lower bound (inclusive). - * @param {Number} [max] upper bound (exclusive). - * @return {Number} random number. - * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -126,8 +121,9 @@ function random(p5, fn){ * * describe('A black dot appears in a random position on a gray square.'); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -143,8 +139,9 @@ function random(p5, fn){ * * describe('A black dot appears in a random position on a gray square.'); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -165,8 +162,9 @@ function random(p5, fn){ * * describe('An animal face is displayed at random. Either a lion, tiger, or bear.'); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -187,8 +185,9 @@ function random(p5, fn){ * strokeWeight(5); * point(x, y); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -209,8 +208,9 @@ function random(p5, fn){ * strokeWeight(5); * point(x, y); * } + * ``` * - * @example + * ```js example * let x = 50; * let y = 50; * @@ -230,6 +230,7 @@ function random(p5, fn){ * // Draw the point. * point(x, y); * } + * ``` * * `random()` can also be used in shaders with p5.strands. The following example * uses `random()` to create varying colors on a shape. @@ -259,6 +260,11 @@ function random(p5, fn){ * sphere(30); * } * ``` + * + * @method random + * @param {Number} [min] lower bound (inclusive). + * @param {Number} [max] upper bound (exclusive). + * @return {Number} random number. */ /** * @method random diff --git a/src/utilities/time_date.js b/src/utilities/time_date.js index 5b85c4dcbb..5b0b4c154b 100644 --- a/src/utilities/time_date.js +++ b/src/utilities/time_date.js @@ -108,10 +108,8 @@ function timeDate(p5, fn){ * sketch includes asynchronous loading using `async`/`await`, then * `millis()` begins tracking time as soon as the asynchronous code * starts running. - * @method millis - * @return {Number} number of milliseconds since starting the sketch. * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -132,8 +130,9 @@ function timeDate(p5, fn){ * `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.` * ); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -154,8 +153,9 @@ function timeDate(p5, fn){ * // Display how long the sketch has run. * text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90); * } + * ``` * - * @example + * ```js example * function setup() { * createCanvas(100, 100); * @@ -174,8 +174,9 @@ function timeDate(p5, fn){ * // Draw the circle. * circle(x, 50, 30); * } + * ``` * - * @example + * ```js example * async function setup() { * // Load the GeoJSON. * await loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); @@ -198,6 +199,7 @@ function timeDate(p5, fn){ * `The text "It took ${round(ms, 2)} ms to load the data" written in black on a gray background.` * ); * } + * ``` * * `millis()` can also be used in shaders with p5.strands. The following example * uses `millis()` to create time-based color transitions on a shape. @@ -228,6 +230,9 @@ function timeDate(p5, fn){ * sphere(30); * } * ``` + * + * @method millis + * @return {Number} number of milliseconds since starting the sketch. */ fn.millis = function() { if (this._millisStart === -1) {