---
title: function-reference.md
tags: mewa-programming-reference
description: Mewa - Video Creator & Compositor
---
### Functions
Below is the list functions supported in Mewa scripts.
Function names are shown as chapters to make the navigation easier thought the side menu.
If you need a function that is not currently available please [contact us](https://www.mewatools.com), we want to help you.
#### clearAll()
It deletes all curves and nodes. The same as cleaning the workspace.
#### connect( outNodeName, outputIndex, inNodeName, inputIndex )
Adds a top-down (output to input) connection between output of *outNodeName* and input of *inNodeName* node.
*outputIndex* and *inputIndex* are the output port and input port indexes respectively.
Node input ports are indexed from 0 to N, where N is the number of input ports. In other words, the first input port of a node has index 0, the second input has index 1, and so on.
Example:
```javascript
connect("ColorWheel", 0, "OverlayBlend", 0);
```
#### curve( name )
Returns the curve with the given *name*
#### delete( var1, var2, ... )
*delete* function deletes script variables. Accepts as input arguments a list of variables names.
The example below creates a ColorWheelNode.
```javascript
myNode = ColorWheelNode();
delete( myNode );
```
Note that *myNode* is a script variable. Calling *delete* only deletes the variable, not the node. To delete a node see the [nodegraph class]().
#### deleteAll()
Deletes all variables.
Note that deleting a variable does not necessarily delete the data referenced by the variable.
See also [delete()](#delete-var1-var2-%E2%80%A6-
).
#### node( name )
Returns the [node](https://hackmd.io/akGwvXj5QHSWS4m-6K8ggg#Node) with the given *name*.
#### nodegraph()
Returns the [Nodegraph](https://hackmd.io/akGwvXj5QHSWS4m-6K8ggg#Nodegraph) object.
### Classes
[Curve](https://hackmd.io/@k--5gSDXTFSeySUer_0emQ/rJvmvT_bc)
[ColorWheelNode](https://hackmd.io/@k--5gSDXTFSeySUer_0emQ/HJND11tWq)
[ShaderNode](https://hackmd.io/@k--5gSDXTFSeySUer_0emQ/SJ5TqfY-5)
#### Dialog
##### Contructors
* Dialog( *text* )
* Dialog( *text* , *title* )
Creates and shows a Dialog with text. The title argument is optional.
Example:
```javascript
dialog = Dialog("Do you wish to continue?");
dialog.addButton("Continue"); // button 0
dialog.addButton("Cancel"); // button 1
clickedOption = dialog.wait();
if( clickedOption == 1 ) { // if clicked cancel button
dialog.close();
return;
}
dialog.setText("Downloading update...");
clickedOption = dialog.wait();
```
##### addButton( text )
```javascript
dialog = Dialog("Do you wish to continue?");
dialog.addButton("Continue");
dialog.addButton("Cancel");
clickedOption = dialog.wait(); // returns the button index when clicked
if( clickedOption == 1 ) { // clicked cancel button
dialog.close();
return;
}
```
##### addButton( text, functionHandler )
Example:
```javascript
function onOkButton()
{
dialog.close();
}
dialog = Dialog("Downloading update...");
dialog.addButton( "Ok", onOkButton );
```
##### setProgress( percent )
Progress value needs to be between 0 and 1.
To hide the progress bar set a negative value (< 0).
To show a running progress set a value bigger than 1 (> 1).
##### setTitle( title )
set empty text to hide
##### setText( text )
set empty text to hide
##### wait()
Returns only when a button is clicked. The returned
value is the index of the clicked button.
##### close()
Closes and hides the dialog.
#### Dir
##### cd( dirName )
Enters directory *dirName*.
Returns true if successfull.
##### exists( name )
*name* is a file or directory name.
Returns true if file/dir exists.
##### size( name )
Returns the file size of the given file *name*.
Returns -1 if the file does not exist.
##### delete( name )
Deletes the file or directory with given *name*.
##### makeDir( name )
#### Download Class Reference
Contructors:
* Download( dir, url )
Starts a downloads the specified ''url'' to the given ''dir''.
##### progress()
Returns the downloaded data size in bytes.
##### status()
Return an integer, that can be either 1, 2 or 3:
1. in progress
2. completed
3. failed
##### cancel()
Cancels the running download.
#### FootageNode Class Reference
##### Constructors
* FootageNode( source )
* FootageNode( source, pos, name )
*source* is a video filename or a list of filenames of images (image sequence).
*pos* is a vector with 2 numbers.
```javascript
node = FootageNode( "C:\MyVideos\sun.mp4" );
```
See also [[#Node|Node class]].
#### Move2DNode Class Reference
##### Constructors
* Move2DNode()
* Move2DNode( name, pos )
The constructor *Move2DNode()* adds a new Move2D node to the node-graph. The name and position of the node are automatically filled.
The constructor *Move2DNode( name, pos )* adds a new Move2D node to the node-graph with the given *name* and at given *pos*. This constructor is used to save and restore a node-graph.
#### Nodegraph Class Reference
The [nodegraph() function](# Functions) returns a Nodegraph object.
##### setTranslation( x, y )
Translates the node-graph view to position ''x,y''.
#### Node Class Reference
*Node* is the base class for all Mewa nodes, like [[#FootageNode]] and [[#ShaderNode]].
##### setName( name )
Sets the given ''name'' to the node. If the name already exist, a number is added at the end of the name
in order to make it unique.
##### setPos( x, y )
Sets the node at the given *x* and *y* position in the nodegraph view.
##### setHelpPage( url )
[panel image]
Use this function associate a help page to a node. The help page is url link.
The link is opened in the system web browser when the user clicks [help button] located at the top of node parameters window.
##### setValue( parameterName, value )
Used to set values to node parameters.
Examples:
```javascript
node.setValue("Color", 0.2, 0.8, 0.4);
```
```javascript
node.setValue("Brightness", 0.44);
```
Associate a curve to a parameter:
```javascript
node.setValue("Brightness", "curve(curveName).value(frame())" );
```
Link parameter from another node:
```javascript
node.setValue("Brightness", "node(nodeName).value( parameterName, 0)" );
```
##### value( parameterName, index )
Parameters can have 1, 2 or 3 values. This function returns the parameter's value at the given *index*.
```javascript
red = node.value("Color", 0 );
green = node.value("Color", 1 );
blue = node.value("Color", 2 );
```
#### ColorControl
*Color Control*
Create a color control initialized with red color. ''uColor'' is the name of the ''vec3'' uniform variable in the glsl shader code.
```javascript
parameter = node.addColorControl("uColor", 0.8, 0.2, 0.2 );
```
Color control has 3 parameters, one for each color channel.
##### setName( name )
Sets the name of this control.
*name* is shown in the control as a text label.
See also [Controls section](https://hackmd.io/akGwvXj5QHSWS4m-6K8ggg?view#Controls).
#### FloatControl
The code below, taken from [Ether.mw](https://mewatools.com/webstore/index.php?view=Ether), shows how a FloatControl is used.
The function ''addFloatControl'' creates a control, adds it to the node panel and returns the control for further setup.
```javascript
parameter = node.addFloatControl("uDelta", 2.5);
parameter.setName("Delta");
parameter.setStep(0.01);
parameter.setRange(-2, 7);
```
##### setRange( min, max )
Sets a minimum and maximum value a parameter can have.
To disable min and max, letting the UI control to reach any value set the same value for min and max (min == max).
##### setStep( increment )
Adjust the step value to make a parameter increase faster or slower with the mouse movement.
##### setName( name )
Sets the name of this control.
*name* is shown in the control as a text label.
The control name should be unique within the node as the ''name'' can be used in the control search.
#### Vec2Control
##### setName( name )
Sets the name of this control.
''name'' is shown in the control as a text label.
See also [Controls](https://hackmd.io/akGwvXj5QHSWS4m-6K8ggg?view#Controls).