// This file was auto-generated. Please do not edit it.
import p5 = require("../../index");
declare module '../../index' {
class MediaElement extends Element {
/**
* Extends p5.Element to handle audio and video. In
* addition to the methods of p5.Element, it also
* contains methods for controlling media. It is not
* called directly, but p5.MediaElements are created
* by calling createVideo, createAudio, and
* createCapture.
*
* @param elt DOM node that is wrapped
*/
constructor(elt: string);
/**
* Play an HTML5 media element.
* @chainable
*/
play(): MediaElement;
/**
* Stops an HTML5 media element (sets current time to
* zero).
* @chainable
*/
stop(): MediaElement;
/**
* Pauses an HTML5 media element.
* @chainable
*/
pause(): MediaElement;
/**
* Set 'loop' to true for an HTML5 media element, and
* starts playing.
* @chainable
*/
loop(): MediaElement;
/**
* Set 'loop' to false for an HTML5 media element.
* Element will stop when it reaches the end.
* @chainable
*/
noLoop(): MediaElement;
/**
* Set HTML5 media element to autoplay or not. If no
* argument is specified, by default it will
* autoplay.
* @param shouldAutoplay whether the element should
* autoplay
* @chainable
*/
autoplay(shouldAutoplay: boolean): MediaElement;
/**
* Sets volume for this HTML5 media element. If no
* argument is given, returns the current volume.
* @return current volume
*/
volume(): number;
/**
* Sets volume for this HTML5 media element. If no
* argument is given, returns the current volume.
* @param val volume between 0.0 and 1.0
* @chainable
*/
volume(val: number): MediaElement;
/**
* If no arguments are given, returns the current
* playback speed of the element. The speed parameter
* sets the speed where 2.0 will play the element
* twice as fast, 0.5 will play at half the speed,
* and -1 will play the element in normal speed in
* reverse.(Note that not all browsers support
* backward playback and even if they do, playback
* might not be smooth.)
* @return current playback speed of the element
*/
speed(): number;
/**
* If no arguments are given, returns the current
* playback speed of the element. The speed parameter
* sets the speed where 2.0 will play the element
* twice as fast, 0.5 will play at half the speed,
* and -1 will play the element in normal speed in
* reverse.(Note that not all browsers support
* backward playback and even if they do, playback
* might not be smooth.)
* @param speed speed multiplier for element playback
* @chainable
*/
speed(speed: number): MediaElement;
/**
* If no arguments are given, returns the current
* time of the element. If an argument is given the
* current time of the element is set to it.
* @return current time (in seconds)
*/
time(): number;
/**
* If no arguments are given, returns the current
* time of the element. If an argument is given the
* current time of the element is set to it.
* @param time time to jump to (in seconds)
* @chainable
*/
time(time: number): MediaElement;
/**
* Returns the duration of the HTML5 media element.
* @return duration
*/
duration(): number;
/**
* Schedule an event to be called when the audio or
* video element reaches the end. If the element is
* looping, this will not be called. The element is
* passed in as the argument to the onended callback.
* @param callback function to call when the
* soundfile has ended. The media element will be
* passed in as the argument to the callback.
* @chainable
*/
onended(callback: (...args: any[]) => any): MediaElement;
/**
* Send the audio output of this element to a
* specified audioNode or p5.sound object. If no
* element is provided, connects to p5's main output.
* That connection is established when this method is
* first called. All connections are removed by the
* .disconnect() method. This method is meant to be
* used with the p5.sound.js addon library.
* @param audioNode AudioNode from the Web Audio API,
* or an object from the p5.sound library
*/
connect(audioNode: AudioNode | object): void;
/**
* Disconnect all Web Audio routing, including to
* main output. This is useful if you want to
* re-route the output through audio effects, for
* example.
*/
disconnect(): void;
/**
* Show the default MediaElement controls, as
* determined by the web browser.
*/
showControls(): void;
/**
* Hide the default mediaElement controls.
*/
hideControls(): void;
/**
* Schedule events to trigger every time a
* MediaElement (audio/video) reaches a playback cue
* point. Accepts a callback function, a time (in
* seconds) at which to trigger the callback, and an
* optional parameter for the callback.
*
* Time will be passed as the first parameter to the
* callback function, and param will be the second
* parameter.
* @param time Time in seconds, relative to this
* media element's playback. For example, to trigger
* an event every time playback reaches two seconds,
* pass in the number 2. This will be passed as the
* first parameter to the callback function.
* @param callback Name of a function that will be
* called at the given time. The callback will
* receive time and (optionally) param as its two
* parameters.
* @param [value] An object to be passed as the
* second parameter to the callback function.
* @return id ID of this cue, useful for
* removeCue(id)
*/
addCue(time: number, callback: (...args: any[]) => any, value?: object): number;
/**
* Remove a callback based on its ID. The ID is
* returned by the addCue method.
* @param id ID of the cue, as returned by addCue
*/
removeCue(id: number): void;
/**
* Remove all of the callbacks that had originally
* been scheduled via the addCue method.
* @param id ID of the cue, as returned by addCue
*/
clearCues(id: number): void;
/**
* Path to the media element source.
*/
src: any;
}
class File {
/**
* Base class for a file. Used for Element.drop and
* createFileInput.
*
* @param file File that is wrapped
*/
constructor(file: File);
/**
* Underlying File object. All normal File methods
* can be called on this.
*/
file: any;
/**
* File type (image, text, etc.)
*/
type: any;
/**
* File subtype (usually the file extension jpg, png,
* xml, etc.)
*/
subtype: any;
/**
* File name
*/
name: any;
/**
* File size
*/
size: any;
/**
* URL string containing either image data, the text
* contents of the file or a parsed object if file is
* JSON and p5.XML if XML
*/
data: any;
}
interface p5InstanceExtensions {
/**
* Searches the page for the first element that
* matches the given CSS selector string (can be an
* ID, class, tag name or a combination) and returns
* it as a p5.Element. The DOM node itself can be
* accessed with .elt. Returns null if none found.
* You can also specify a container to search within.
* @param selectors CSS selector string of element to
* search for
* @param [container] CSS selector string,
* p5.Element, or HTML element to search within
* @return p5.Element containing node found
*/
select(selectors: string, container?: string | Element | HTMLElement): Element | null;
/**
* Searches the page for elements that match the
* given CSS selector string (can be an ID a class,
* tag name or a combination) and returns them as
* p5.Elements in an array. The DOM node itself can
* be accessed with .elt. Returns an empty array if
* none found. You can also specify a container to
* search within.
* @param selectors CSS selector string of elements
* to search for
* @param [container] CSS selector string, p5.Element
* , or HTML element to search within
* @return Array of p5.Elements containing nodes
* found
*/
selectAll(selectors: string, container?: string | Element | HTMLElement): Element[];
/**
* Removes all elements created by p5, except any
* canvas / graphics elements created by createCanvas
* or createGraphics. Event handlers are removed, and
* element is removed from the DOM.
*/
removeElements(): void;
/**
* The .changed() function is called when the value
* of an element changes. This can be used to attach
* an element specific event listener.
* @param fxn function to be fired when the value of
* an element changes. if false is passed instead,
* the previously firing function will no longer
* fire.
* @chainable
*/
changed(fxn: ((...args: any[]) => any) | boolean): p5;
/**
* The .input() function is called when any user
* input is detected with an element. The input event
* is often used to detect keystrokes in a input
* element, or changes on a slider element. This can
* be used to attach an element specific event
* listener.
* @param fxn function to be fired when any user
* input is detected within the element. if false is
* passed instead, the previously firing function
* will no longer fire.
* @chainable
*/
input(fxn: ((...args: any[]) => any) | boolean): p5;
/**
* Creates a
element in the DOM with
* given inner HTML.
* @param [html] inner HTML for element created
* @return pointer to p5.Element holding created node
*/
createDiv(html?: string): Element;
/**
* Creates a element in the DOM with given
* inner HTML. Used for paragraph length text.
* @param [html] inner HTML for element created
* @return pointer to p5.Element holding created node
*/
createP(html?: string): Element;
/**
* Creates a element in the DOM with
* given inner HTML.
* @param [html] inner HTML for element created
* @return pointer to p5.Element holding created node
*/
createSpan(html?: string): Element;
/**
* Creates an element in the DOM with given src
* and alternate text.
* @param src src path or url for image
* @param alt alternate text to be used if image does
* not load. You can use also an empty string ("") if
* that an image is not intended to be viewed.
* @return pointer to p5.Element holding created node
*/
createImg(src: string, alt: string): Element;
/**
* Creates an element in the DOM with given src
* and alternate text.
* @param src src path or url for image
* @param alt alternate text to be used if image does
* not load. You can use also an empty string ("") if
* that an image is not intended to be viewed.
* @param crossOrigin crossOrigin property of the img
* element; use either 'anonymous' or
* 'use-credentials' to retrieve the image with
* cross-origin access (for later use with canvas. if
* an empty string("") is passed, CORS is not used
* @param [successCallback] callback to be called
* once image data is loaded with the p5.Element as
* argument
* @return pointer to p5.Element holding created node
*/
createImg(src: string, alt: string, crossOrigin: string, successCallback?: (...args: any[]) => any): Element;
/**
* Creates an element in the DOM for
* including a hyperlink.
* @param href url of page to link to
* @param html inner html of link element to display
* @param [target] target where new link should open,
* could be _blank, _self, _parent, _top.
* @return pointer to p5.Element holding created node
*/
createA(href: string, html: string, target?: string): Element;
/**
* Creates a slider element in the
* DOM. Use .size() to set the display length of the
* slider.
* @param min minimum value of the slider
* @param max maximum value of the slider
* @param [value] default value of the slider
* @param [step] step size for each tick of the
* slider (if step is set to 0, the slider will move
* continuously from the minimum to the maximum
* value)
* @return pointer to p5.Element holding the created
* node
*/
createSlider(min: number, max: number, value?: number, step?: number): Element;
/**
* Creates a element in the DOM.
* Use .size() to set the display size of the button.
* Use .mousePressed() to specify behavior on press.
* @param label label displayed on the button
* @param [value] value of the button
* @return pointer to p5.Element holding created node
*/
createButton(label: string, value?: string): Element;
/**
* Creates a checkbox element in the
* DOM. Calling .checked() on a checkbox returns a
* boolean indicating whether it is checked or not.
* @param [label] label displayed after checkbox
* @param [value] value of the checkbox; checked is
* true, unchecked is false
* @return pointer to p5.Element holding created node
*/
createCheckbox(label?: string, value?: boolean): Element;
/**
* Creates a dropdown menu element
* in the DOM. It also assigns select-related methods
* to p5.Element when selecting an existing select
* box. Options in the menu are unique by name (the
* display text). - .option(name, [value]) can be
* used to add an option with name (the display text)
* and value to the select element. If an option with
* name already exists within the select element,
* this method will change its value to value.
* - .value() will return the currently selected
* option.
* - .selected() will return the current dropdown
* element which is an instance of p5.Element.
* - .selected(value) can be used to make given
* option selected by default when the page first
* loads.
* - .disable() marks the whole dropdown element as
* disabled.
* - .disable(value) marks a given option as
* disabled.
* - .enable() marks the whole dropdown element as
* enabled if whole dropdown element is disabled
* intially.
* - .enable(value) marks a given option as enable if
* the initial option is disabled.
* @param [multiple] true if dropdown should support
* multiple selections
* @return pointer to p5.Element holding created node
*/
createSelect(multiple?: boolean): Element;
/**
* Creates a dropdown menu element
* in the DOM. It also assigns select-related methods
* to p5.Element when selecting an existing select
* box. Options in the menu are unique by name (the
* display text). - .option(name, [value]) can be
* used to add an option with name (the display text)
* and value to the select element. If an option with
* name already exists within the select element,
* this method will change its value to value.
* - .value() will return the currently selected
* option.
* - .selected() will return the current dropdown
* element which is an instance of p5.Element.
* - .selected(value) can be used to make given
* option selected by default when the page first
* loads.
* - .disable() marks the whole dropdown element as
* disabled.
* - .disable(value) marks a given option as
* disabled.
* - .enable() marks the whole dropdown element as
* enabled if whole dropdown element is disabled
* intially.
* - .enable(value) marks a given option as enable if
* the initial option is disabled.
* @param existing DOM select element
*/
createSelect(existing: object): Element;
/**
* Creates a radio button element in the DOM. It also
* helps existing radio buttons assign methods of
* p5.Element. - .option(value, [label]) can be used
* to create a new option for the element. If an
* option with a value already exists, it will be
* returned. It is recommended to use string values
* as input for value. Optionally, a label can be
* provided as second argument for the option.
* - .remove(value) can be used to remove an option
* for the element. String values recommended as
* input for value.
* - .value() method will return the currently
* selected value.
* - .selected() method will return the currently
* selected input element.
* - .selected(value) method will select the option
* and return it. String values recommended as input
* for value.
* - .disable(Boolean) method will enable/disable the
* whole radio button element.
* @param containerElement A container HTML Element,
* either a div or span, inside which all existing
* radio inputs will be considered as options.
* @param [name] A name parameter for each Input
* Element.
* @return pointer to p5.Element holding created node
*/
createRadio(containerElement: object, name?: string): Element;
/**
* Creates a radio button element in the DOM. It also
* helps existing radio buttons assign methods of
* p5.Element. - .option(value, [label]) can be used
* to create a new option for the element. If an
* option with a value already exists, it will be
* returned. It is recommended to use string values
* as input for value. Optionally, a label can be
* provided as second argument for the option.
* - .remove(value) can be used to remove an option
* for the element. String values recommended as
* input for value.
* - .value() method will return the currently
* selected value.
* - .selected() method will return the currently
* selected input element.
* - .selected(value) method will select the option
* and return it. String values recommended as input
* for value.
* - .disable(Boolean) method will enable/disable the
* whole radio button element.
* @param name A name parameter for each Input
* Element.
* @return pointer to p5.Element holding created node
*/
createRadio(name: string): Element;
/**
* Creates a radio button element in the DOM. It also
* helps existing radio buttons assign methods of
* p5.Element. - .option(value, [label]) can be used
* to create a new option for the element. If an
* option with a value already exists, it will be
* returned. It is recommended to use string values
* as input for value. Optionally, a label can be
* provided as second argument for the option.
* - .remove(value) can be used to remove an option
* for the element. String values recommended as
* input for value.
* - .value() method will return the currently
* selected value.
* - .selected() method will return the currently
* selected input element.
* - .selected(value) method will select the option
* and return it. String values recommended as input
* for value.
* - .disable(Boolean) method will enable/disable the
* whole radio button element.
* @return pointer to p5.Element holding created node
*/
createRadio(): Element;
/**
* Creates a colorPicker element in the DOM for color
* input. The .value() method will return a hex
* string (#rrggbb) of the color. The .color() method
* will return a p5.Color object with the current
* chosen color.
* @param [value] default color of element
* @return pointer to p5.Element holding created node
*/
createColorPicker(value?: string | Color): Element;
/**
* Creates an element in the DOM for
* text input. Use .size() to set the display length
* of the box.
* @param value default value of the input box
* @param [type] type of text, ie text, password etc.
* Defaults to text. Needs a value to be specified
* first.
* @return pointer to p5.Element holding created node
*/
createInput(value: string, type?: string): Element;
/**
* Creates an element in the DOM for
* text input. Use .size() to set the display length
* of the box.
* @param [value] default value of the input box
*/
createInput(value?: string): Element;
/**
* Creates an element in the DOM of
* type 'file'. This allows users to select local
* files for use in a sketch.
* @param callback callback function for when a file
* is loaded
* @param [multiple] optional, to allow multiple
* files to be selected
* @return pointer to p5.Element holding created DOM
* element
*/
createFileInput(callback: (...args: any[]) => any, multiple?: boolean): Element;
/**
* Creates an HTML5