UNPKG

p5

Version:

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

296 lines (285 loc) 6.42 kB
// This file is auto-generated from JSDoc documentation import p5 from 'p5'; declare module 'p5' { /** * Returns the current day as a number from 1–31. * * @return current day between 1 and 31. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the current day. * let d = day(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(12); * textFont('Courier New'); * * // Display the day. * text(`Current day: ${d}`, 20, 50, 60); * * describe(`The text 'Current day: ${d}' written in black on a gray background.`); * } * </code> * </div> */ function day(): number; /** * Returns the current hour as a number from 0–23. * * @return current hour between 0 and 23. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the current hour. * let h = hour(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(12); * textFont('Courier New'); * * // Display the hour. * text(`Current hour: ${h}`, 20, 50, 60); * * describe(`The text 'Current hour: ${h}' written in black on a gray background.`); * } * </code> * </div> */ function hour(): number; /** * Returns the current minute as a number from 0–59. * * @return current minute between 0 and 59. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the current minute. * let m = minute(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(12); * textFont('Courier New'); * * // Display the minute. * text(`Current minute: ${m}`, 10, 50, 80); * * describe(`The text 'Current minute: ${m}' written in black on a gray background.`); * } * </code> * </div> */ function minute(): number; /** * Returns the number of milliseconds since a sketch started running.`millis()` keeps track of how long a sketch has been running in * milliseconds (thousandths of a second). This information is often * helpful for timing events and animations.If a sketch has a * setup() function, then `millis()` begins tracking * time before the code in setup() runs. If a * sketch includes asynchronous loading using `async`/`await`, then * `millis()` begins tracking time as soon as the asynchronous code * starts running. * * @return number of milliseconds since starting the sketch. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the number of milliseconds the sketch has run. * let ms = millis(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(10); * textFont('Courier New'); * * // Display how long it took setup() to be called. * text(`Startup time: ${round(ms, 2)} ms`, 5, 50, 90); * * describe( * `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.` * ); * } * </code> * </div> * * <div> * <code> * function setup() { * createCanvas(100, 100); * * describe('The text "Running time: S sec" written in black on a gray background. The number S increases as the sketch runs.'); * } * * function draw() { * background(200); * * // Get the number of seconds the sketch has run. * let s = millis() / 1000; * * // Style the text. * textAlign(LEFT, CENTER); * textSize(10); * textFont('Courier New'); * * // Display how long the sketch has run. * text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90); * } * </code> * </div> * * <div> * <code> * function setup() { * createCanvas(100, 100); * * describe('A white circle oscillates left and right on a gray background.'); * } * * function draw() { * background(200); * * // Get the number of seconds the sketch has run. * let s = millis() / 1000; * * // Calculate an x-coordinate. * let x = 30 * sin(s) + 50; * * // Draw the circle. * circle(x, 50, 30); * } * </code> * </div> * * <div> * <code> * async function setup() { * // Load the GeoJSON. * await loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); * createCanvas(100, 100); * * background(200); * * // Get the number of milliseconds the sketch has run. * let ms = millis(); * * // Style the text. * textAlign(LEFT, CENTER); * textFont('Courier New'); * textSize(11); * * // Display how long it took to load the data. * text(`It took ${round(ms, 2)} ms to load the data`, 5, 50, 100); * * describe( * `The text "It took ${round(ms, 2)} ms to load the data" written in black on a gray background.` * ); * } * </code> * </div> */ function millis(): number; /** * Returns the current month as a number from 1–12. * * @return current month between 1 and 12. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the current month. * let m = month(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(12); * textFont('Courier New'); * * // Display the month. * text(`Current month: ${m}`, 10, 50, 80); * * describe(`The text 'Current month: ${m}' written in black on a gray background.`); * } * </code> * </div> */ function month(): number; /** * Returns the current second as a number from 0–59. * * @return current second between 0 and 59. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the current second. * let s = second(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(12); * textFont('Courier New'); * * // Display the second. * text(`Current second: ${s}`, 10, 50, 80); * * describe(`The text 'Current second: ${s}' written in black on a gray background.`); * } * </code> * </div> */ function second(): number; /** * Returns the current year as a number such as 1999. * * @return current year. * @example <div> * <code> * function setup() { * createCanvas(100, 100); * * background(200); * * // Get the current year. * let y = year(); * * // Style the text. * textAlign(LEFT, CENTER); * textSize(12); * textFont('Courier New'); * * // Display the year. * text(`Current year: ${y}`, 10, 50, 80); * * describe(`The text 'Current year: ${y}' written in black on a gray background.`); * } * </code> * </div> */ function year(): number; } export default function time_date(p5: any, fn: any): void;