Reference

This info is generated from the function reference inside Mad Tea Lab

Helper:

  • out(c, […]) – text output
  • dirt(x) – Low amp. Noise
  • marker(x,a)
  • F(text) – Create Function
  • sample(function,range)
  • aToF(array [,filter,begin,end])
  • aToFn(array [,filter])

Periodic:

  • saw(x [,n=1]) – 0 to 1
  • saw0(x, [,n=1]) – -1 to 1
  • tri(x, [,n=1]) – 0 to 1
  • tri0(x, [,n=1]) – -1 to 1

Graphics:

Color Processing:

Generators:

Restrict:

Decimate:

  • round(x [,decimals] )
  • floor(x) – Floor function
  • ceil(x) – Ceiling function
  • int(x) – Integer function
  • sgn(x) – Sign
  • H(x) – Heaviside step

Number Generation:

  • rnd0() – Range -1 <1
  • rnd() – Range 0 <1
  • rndi(c) – Integer, 0
  • rand() – Integer, 0 <232
  • randn() – Normal dist.
  • intHash(x) – Integer Hash
  • hash(x) – 0 – <1
  • hash0(x) – -1 – <1

Basic Math:

  • sqr(x) – x2 (Square)
  • cube(x) – x3 (Cube)
  • sqrFlip(x) – 1-(1-x)2
  • cubeFlip(x) – 1-(1-x)3
  • sqrt(x) – Square Root
  • pow(b,x) – bx
  • exp(x) – ex
  • exp2(x) – 2x
  • log(x) – Logarithm (e)
  • log10(x) – Logarithm (10)
  • log2(x) – Logarithm (2)
  • logx(b,x) – Logarithm (b)

Math:

Trigonometry:

  • sin(x) – Sine
  • cos(x) – Cosine
  • tan(x) – Tangent
  • abs(x) – Absolute value
  • acos(x) – Inverse cosine
  • asin(x) – Inverse sine
  • atan(x) – Inverse tangent
  • atan2(y,x) – Inverse tangent
  • sinh(x) – Sine Hyperholic
  • cosh(x) – Cosine Hyperholic

Complex Math:

Time:

Helper:

out

out(c, […]) text output
Write text to the output box
Mad Tea Lab Example


dirt

dirt(x) Low amp. Noise
A hash-based, uniformly distributed noise, with a scaling of 1/32
Mad Tea Lab Example


marker

marker(x,a)
GUI helper, just a function that is very steep at (a)
Mad Tea Lab Example


F

F(text) Create Function
Creates a function from string, arguments are assumed to be (x,y,z)
Mad Tea Lab Example


sample

sample(function,range)
Samples a function N times and returns an array with the sampled data, range is specified as an array [begin_value, end_value, N]
Mad Tea Lab Example


aToF

aToF(array [,filter,begin,end])
Array-To-Function, filter can be nearest, linear (default), hermite, quadratic or cubic. Default value of begin is 0. Default value of end is array.length-1
Mad Tea Lab Example


aToFn

aToFn(array [,filter])
Array-To-Function, same as aToF but with hardwired begin=0 and end=1
Mad Tea Lab Example

Periodic:

saw

saw(x [,n=1]) 0 to 1
Period n, out values 0 to 1
Mad Tea Lab Example


saw0

saw0(x, [,n=1]) -1 to 1
Period n, out values -1 to 1
Mad Tea Lab Example


tri

tri(x, [,n=1]) 0 to 1
Period n*2, out values 0 to 1
Mad Tea Lab Example


tri0

tri0(x, [,n=1]) -1 to 1
Period n*2, out values -1 to 1
Mad Tea Lab Example

Graphics:

point

point(x,y,z,size)
Draw a Point
Mad Tea Lab Example


rect

rect(x,y,width,height)
Draw a 2D rectangle
Mad Tea Lab Example
Wikipedia on Rectangle


ellipse

ellipse(x,y,width,height)
Draw an ellipse
Mad Tea Lab Example
Wikipedia on Ellipse


circle

circle(x,y,radius)
Draw a circle
Mad Tea Lab Example
Wikipedia on Circle


line

line( coords * 2 )
Draw a line segment, both 2D and 3D coordinates are accepted
Mad Tea Lab Example
Wikipedia on Line segment


triangle

triangle( coords * 3 )
Draw a triangle, both 2D and 3D coordinates are accepted
Mad Tea Lab Example
Wikipedia on Triangle


quad

quad( coords * 4 )
Draw a quadrilateral, both 2D and 3D coordinates are accepted
Mad Tea Lab Example
Wikipedia on Quadrilateral


beginShape

beginShape([primitive])
Begin shape drawing, primitives are LINE_STRIP (default), LINES, TRIANGLES and QUADS
Mad Tea Lab Example


vertex

vertex( coord )
Must be called within calls to beginShape/endShape
Mad Tea Lab Example


endShape

endShape([CLOSE])
End (and draw) a shape, for the LINE_STRIP primitive, passing CLOSE to the function will close the shape
Mad Tea Lab Example


screenSpace

screenSpace()
Set drawing coordinates to be related to canvas pixels
Mad Tea Lab Example


plotSpace

plotSpace()
Set drawing coordinates to be related to the current view of the graph
Mad Tea Lab Example


scale

scale(x [,y,z])
Scale the drawing space for future drawing, scale(2) will scale x,y,z by 2 (uniformly)
Mad Tea Lab Example


translate

translate(x,y [,z])
Offset the drawing space for future rendering
Mad Tea Lab Example


rotate

rotate(a)
Rotates the drawing space (x,y) for future rendering
Mad Tea Lab Example


rotateX

rotateX(a)
Rotates the drawing space (y,z) for future rendering
Mad Tea Lab Example


rotateY

rotateY(a)
Rotates the drawing space (x,z) for future rendering
Mad Tea Lab Example


fill

fill(color [,alpha])
Color can be supplied as r,g,b (range 0 to 255), gray (0 to 255), [r,b,g] (range 0 to 1) or hex. Alpha is in range 0 to 255.
Mad Tea Lab Example


stroke

stroke(color [,alpha])
Color can be supplied as r,g,b (range 0 to 255), gray (0 to 255), [r,b,g] (range 0 to 1) or hex. Alpha is in range 0 to 255.
Mad Tea Lab Example


noFill

noFill()
Disable Fill
Mad Tea Lab Example


noStroke

noStroke()
Disable Stroke
Mad Tea Lab Example


loadImage

loadImage(name)
Load image to browser cache and display thumbnail
Mad Tea Lab Example


imageMode

imageMode(mode)
Sets mode for function image(), valid modes are CORNER (default), CORNERS and CENTER
Mad Tea Lab Example


image

image(x,y,w,h)
Draws an image
Mad Tea Lab Example

Color Processing:

toHSV

toHSV(rgb)
Input is [R,G,B] each in range 0 to 1, output is [H,S,V] each in range 0 to 1
Mad Tea Lab Example
Wikipedia on HSL and HSV


fromHSV

fromHSV(hsv)
Input is [H,S,V] each in range 0 to 1, output is [R,G,B] each in range 0 to 1
Mad Tea Lab Example
Wikipedia on HSL and HSV


toHSL

toHSL(rgb)
Input is [R,G,B] each in range 0 to 1, output is [H,S,L] each in range 0 to 1
Mad Tea Lab Example
Wikipedia on HSL and HSV


fromHSL

fromHSL(hsl)
Input is [H,S,L] each in range 0 to 1, output is [R,G,B] each in range 0 to 1
Mad Tea Lab Example
Wikipedia on HSL and HSV


toYUV

toYUV(rgb [,Kr,Kb,Sr,Sb])
Input is [R,G,B] each in range 0 to 1, output is [Y,U,V] each in range 0 to 1
Mad Tea Lab Example
Wikipedia on YUV


fromYUV

fromYUV(yuv [,Kr,Kb,Sr,Sb])
Input is [Y,U,V] each in range 0 to 1, output is [R,G,B] each in range 0 to 1
Mad Tea Lab Example
Wikipedia on YUV


gradient

gradient(color,brightness)
Generates [R,G,B] the gradient gray-red-yellow-green-cyan-blue-purple-gray between color 0 and 1 (it is periodic, so any value can be supplied), brigthness is in range 0 (black) to 1 (white)
Mad Tea Lab Example


forEachChannel

forEachChannel(…)
Iterates each color-channel, c is the color value (range 0 to 255)
Mad Tea Lab Example


forEachChannelXY

forEachChannelXY(…)
Iterates each color-channel, c is the color value (range 0 to 255)
Mad Tea Lab Example


forEachChannelA

forEachChannelA(…)
Iterates each color-channel and gives access to nearby pixels, parameters for func are (destinationArray,sourceArray,index,strideY,strideX)
Mad Tea Lab Example


forEachPixel

forEachPixel(…)
Iterates each pixel, r,g,b,a is the color component values (range 0 to 255)
Mad Tea Lab Example


forEachPixelXY

forEachPixelXY(…)
Iterates each pixel, c is the color value (range 0 to 255)
Mad Tea Lab Example


forEachPixelA

forEachPixelA(…)
Iterates each pixel and gives access to nearby pixels, parameters for callback are (destinationArray,sourceArray,index,strideY,strideX), color order is always RGBA
Mad Tea Lab Example

Generators:

gensin

gensin(x)
Sine wave generator, Period 1, out values -1 to 1
Mad Tea Lab Example
Wikipedia on Sine wave


gencos

gencos(x)
Cosine wave generator, Period 1, out values -1 to 1
Mad Tea Lab Example
Wikipedia on Sine wave


gentri

gentri(x[,n]) n for bandlim.
Triangle wave generator, Period 1, out values -1 to 1
Mad Tea Lab Example
Wikipedia on Triangle wave


gensaw

gensaw(x[,n]) n for bandlim.
Sawtooth wave generator, Period 1, out values -1 to 1
Mad Tea Lab Example
Wikipedia on Sawtooth wave


gensqr

gensqr(x[,n]) n for bandlim.
Square wave generator, Period 1, out values -1 to 1
Mad Tea Lab Example
Wikipedia on Square wave


genpul

genpul(x,d[,n]) n for bandlim.
Pulse wave generator, Period 1, d is the duty cycle, out values -1 to 1
Mad Tea Lab Example
Wikipedia on Pulse wave


genrnd

genrnd(x)
Random generator, period 1, out values -1 to 1
Mad Tea Lab Example


genrndl

genrndl(x) linear interp.
Random generator, linear interpolation, period 1, out values -1 to 1
Mad Tea Lab Example


genrndq

genrndq(x) quadratic interp.
Random generator, quadratic interpolation, Period 1, out values -1 to 1
Mad Tea Lab Example


genrndc

genrndc(x) cubic interp.
Random generator, cubic interpolation, Period 1, out values -1 to 1
Mad Tea Lab Example


gen

gen(x [,which, n]) all-in-one
Interpolated sequence of generators, Period 1, out values -1 to 1
Mad Tea Lab Example


genn

genn(x [,which, n]) 0 to 1
Interpolated sequence of generators, Period 1, out values 0 to 1
Mad Tea Lab Example

Restrict:

min

min(a,b […])
Returns the input that has the lowest value
Mad Tea Lab Example


max

max(a,b […])
Returns the input that has the highest value
Mad Tea Lab Example


clamp

clamp(x [,min=0,max=1])
Restrict values within an interval (default interval 0 to 1)
Mad Tea Lab Example


clampg

clampg(x [,min=0,max=1])
Restrict values within an interval using gaussian distribution
Mad Tea Lab Example


clampw

clampw(x [,min=0,max=1])
Restrict values within an interval, wrap if outside
Mad Tea Lab Example


clampm

clampm(x [,min=0,max=1])
Restrict values within an interval, mirror if outside
Mad Tea Lab Example


clip

clip(x [,min=-1,max=1])
Restrict values within an interval (default interval -1 to 1)
Mad Tea Lab Example


clipg

clipg(x [,min=-1,max=1])
Restrict values within an interval using gaussian distribution
Mad Tea Lab Example


clipw

clipw(x [,min=-1,max=1])
Restrict values within an interval, wrap if outside
Mad Tea Lab Example


clipm

clipm(x [,min=-1,max=1])
Restrict values within an interval, mirror if outside
Mad Tea Lab Example

Decimate:

round

round(x [,decimals] )
Rounding function, rounds to nearest integer (or decimal if defined)
Mad Tea Lab Example
Wikipedia on Rounding


floor

floor(x) Floor function
Floor function, rounds down to the integer below
Mad Tea Lab Example
Wikipedia on Floor function


ceil

ceil(x) Ceiling function
Ceiling function, rounds up to the integer above
Mad Tea Lab Example
Wikipedia on Ceiling function


int

int(x) Integer function
Integer function, just discards decimals
Mad Tea Lab Example


sgn

sgn(x) Sign
Sign function,
returns the sign of the value
sgn(x) = -1 if x<0
sgn(x) = 0 if x=0
sgn(x) = 1 if x>0
Mad Tea Lab Example
Wikipedia on Sign Function


H

H(x) Heaviside step
Heaviside step function
H(x) = 0 if x<0
H(x) = 1/2 if x=0
H(x) = 1 if x>0
Mad Tea Lab Example
Wikipedia on Heaviside step function

Number Generation:

rnd0

rnd0() Range -1 <1
Random values, [Uniform distribution], interval -1 to <1
Mad Tea Lab Example
Wikipedia on Random number generation


rnd

(Alias: random() )

rnd() Range 0 <1
Random values, [Uniform distribution], interval 0 to <1
Mad Tea Lab Example
Wikipedia on Random number generation


rndi

rndi(c) Integer, 0 Random integer values, [Uniform distribution], interval 0 to Mad Tea Lab Example
Wikipedia on Random number generation


rand

rand() Integer, 0 <232
Random integer values, [Uniform distribution], interval 0 to <2^32 (32 bits)
Mad Tea Lab Example
Wikipedia on Random number generation


randn

randn() Normal dist.
Normally distributed random values, Gaussian noise
Mad Tea Lab Example
Wikipedia on Gaussian noise


intHash

intHash(x) Integer Hash
Hash function, Integer input, out values 0 to <2^31, based on Bob Jenkins 32 bit hash
Mad Tea Lab Example
Wikipedia on Hash function


hash

hash(x) 0 – <1
The intHash() function scaled to the range 0 to <1
Mad Tea Lab Example


hash0

hash0(x) -1 – <1
The intHash() function scaled to the range -1 to <1
Mad Tea Lab Example

Basic Math:

sqr

sqr(x) x2 (Square)
Square x
Mad Tea Lab Example
Wikipedia on Square (algebra)


cube

cube(x) x3 (Cube)
Cube x
Mad Tea Lab Example
Wikipedia on Cube (algebra)


sqrFlip

sqrFlip(x) 1-(1-x)2
Square x Flipped
Mad Tea Lab Example


cubeFlip

cubeFlip(x) 1-(1-x)3
Cube x Flipped
Mad Tea Lab Example


sqrt

sqrt(x) Square Root
Square Root
Mad Tea Lab Example
Wikipedia on Square Root


pow

pow(b,x) bx
Power of, raise b to the power of x
Mad Tea Lab Example
Wikipedia on Exponentiation


exp

exp(x) ex
Exponentiation, raise e to the power x
Mad Tea Lab Example
Wikipedia on Exponentiation


exp2

exp2(x) 2x
Powers of two, raise 2 to the power of x
Mad Tea Lab Example
Wikipedia on Exponentiation


log

(Alias: ln(x) )

log(x) Logarithm (e)
Natural Logarithm, base e logarithm
Mad Tea Lab Example
Wikipedia on Logarithm


log10

(Alias: lg(x) )

log10(x) Logarithm (10)
Common Logarithm, base 10 logarithm
Mad Tea Lab Example
Wikipedia on Logarithm


log2

(Alias: lb(x) )

log2(x) Logarithm (2)
Binary Logarithm, base 2 logarithm
Mad Tea Lab Example
Wikipedia on Logarithm


logx

logx(b,x) Logarithm (b)
The inverse of the pow function (using the same base), calculated log(x)/log(b)
Mad Tea Lab Example
Wikipedia on Logarithm

Math:

isPrime

isPrime(a)
Checks if a number is a prime
Mad Tea Lab Example
Wikipedia on Prime number


primes

primes(n)
Returns an array with all the primes in the range 0 to n
Mad Tea Lab Example
Wikipedia on Prime number


factor

factor(n) Prime factorization
Returns an array with the integer prime factors of n
Mad Tea Lab Example
Wikipedia on Prime factorization


gcd

gcd(u,v) Greatest com. div
The Greatest common divisor of two non-zero integers, is the largest positive integer that divides both numbers without remainder.
Mad Tea Lab Example
Wikipedia on Greatest common divisor


lcm

lcm(u,v) Least com. mul
The Least common multiple of two integers a and b is the smallest positive integer that is a multiple both of a and of b.
Mad Tea Lab Example
Wikipedia on Least common multiple


fact

fact(n) Factorial
Factorials n>22 are not correct due to precision
Mad Tea Lab Example
Wikipedia on Factorial


fibo

fibo(n) Fibonacci nr
Fibonacci numbers, n>70 are not correct due to precision
Mad Tea Lab Example
Wikipedia on Fibonacci number


erf

erf(x) Error function
aka Gauss Error function
Mad Tea Lab Example
Wikipedia on Error function


erfi

erfi(x) Inverse Error f.
The Inverse of the Gauss Error function
Mad Tea Lab Example
Wikipedia on Error function


pascalTriangle

pascalTriangle(rowCount)
Generates a number of rows of Pascals Triangle
Mad Tea Lab Example
Wikipedia on Pascals Triangle


ruler

ruler(x,m) (Integers)
The Ruler function, aka Thomaes function, popcorn function, raindrop function, Riemann function
Mad Tea Lab Example
Wikipedia on Ruler function


gamma

gamma(x)
The Gamma function (Real values)
Mad Tea Lab Example
Wikipedia on Gamma function

Trigonometry:

sin

sin(x) Sine
Sine
Mad Tea Lab Example
Wikipedia on Sine


cos

cos(x) Cosine
Cosine
Mad Tea Lab Example
Wikipedia on Cosine


tan

tan(x) Tangent
Tangent
Mad Tea Lab Example
Wikipedia on Trigonometric functions#Tangent


abs

abs(x) Absolute value
Absolute Value

|x| = abs(x)
Mad Tea Lab Example
Wikipedia on Absolute value


acos

acos(x) Inverse cosine
Inverse Cosine, or Arc Cosine
Mad Tea Lab Example
Wikipedia on Inverse cosine


asin

asin(x) Inverse sine
Inverse Sine, or Arc Sine
Mad Tea Lab Example
Wikipedia on Inverse sine


atan

atan(x) Inverse tangent
Inverse Tangent, or Arc Tangent
Mad Tea Lab Example
Wikipedia on Inverse tangent


atan2

atan2(y,x) Inverse tangent
Inverse Tangent, 2 arguments
Mad Tea Lab Example
Wikipedia on Inverse tangent


sinh

sinh(x) Sine Hyperholic
Hyperholic Sine
Mad Tea Lab Example
Wikipedia on Hyperbolic function


cosh

cosh(x) Cosine Hyperholic
Hyperholic Cosine
Mad Tea Lab Example
Wikipedia on Hyperbolic function

Complex Math:

cadd

cadd(a,b) a + b
Complex Addition
Mad Tea Lab Example
Wikipedia on Complex number


cmul

cmul(a,b) a * b
Complex Multiplication
Mad Tea Lab Example
Wikipedia on Complex number


csub

csub(a,b) a – b
Complex Subtraction
Mad Tea Lab Example
Wikipedia on Complex number


cdiv

cdiv(a,b) a / b
Complex Division
Mad Tea Lab Example
Wikipedia on Complex number


cpow

cpow(a,b) ab
Complex Power of
Mad Tea Lab Example


cneg

cneg(z) -z
Complex Negation
Mad Tea Lab Example


cinv

cinv(z) 1 / z
Complex Inverse
Mad Tea Lab Example


csqr

csqr(z) z2
Complex Square
Mad Tea Lab Example


cexp

cexp(z) ez
Complex Exponentiation
Mad Tea Lab Example
Wikipedia on Exponential function#On the complex plane


clog

clog(z) log(z)
Complex Natural Logarothm
Mad Tea Lab Example
Wikipedia on Complex logarithm


cabs

cabs(z) |z|
Complex Absolute value, Magnitude
Mad Tea Lab Example
Wikipedia on Absolute value#Complex numbers


csin

csin(z) sin
Complex Sine
Mad Tea Lab Example


ccos

ccos(z) cos
Complex Cosine
Mad Tea Lab Example


cconj

cconj(z) Conjugate
Complex Conjugate
Mad Tea Lab Example
Wikipedia on Complex conjugate

Time:

year

year()
Get Current Year
Mad Tea Lab Example


month

month()
Get Current Month
Mad Tea Lab Example


day

day()
Get Current Day
Mad Tea Lab Example


hour

hour()
Get Current Hour
Mad Tea Lab Example


minute

minute()
Get Current Minute
Mad Tea Lab Example


second

second()
Get Current Second
Mad Tea Lab Example

Comments are closed.