The AU Library:
Quick Reference

Andrew Glassner
https://The Imaginary Institute
15 October 2014

andrew@imaginary-institute.com
https://www.imaginary-institute.com
http://www.glassner.com
@AndrewGlassner

Imaginary Institute Tech Note #9

Table of Contents

Introduction

This document contains a quick reference to all the functions in the AU Library. For complete documentation, see Imaginary Institute Technical Notes 3 through 8 (see the last section for download information). In particular, Note 3 gives an overview of all the packages in the library. Each section that begins with AU is discussed in more detail in one of the other technical notes.

The sections that begin with AU describe objects. You'll need to create one with the constructor in that section, and then send it messages. For example, you'd use an AUCamera this way:

AUCamera myCamera = new AUCamera(this, 10, 10, true);  // construct a camera
myCamera.expose();  // take a picture

Sections that don't start with AU describe functions that live in the general library. You call them by preceding them with AULib.. For example, to get the value of the S() function at a value of 0.3, you'd write

float v = AULib.S(0.3);

Naming Constants

Several the sections have a list of constants that appear in all capital letters (e.g., DIST_RADIAL). If the section does not begin with AU, then you need to precede these with AULib.). For example, to get a value for a wave of type WAVE_SAWTOOTH), you'd write

float v = AULib.wave(AULib.WAVE_SAWTOOTH, .5, 0);

On the other hand, if the section does begin with AU, then you use the section's name followed by a period. For example, to specify the SHUTTER_UNIFORM) option for an AUCamera) object, you'd write

myCamera.setShutterType(AUCamera.SHUTTER_UNIFORM);

Version Number & Error Reporting

String version();
void setErrorLevel(int errorLevel); 
errorLevel: 
  ERROR_LEVEL_SILENT 
  ERROR_LEVEL_NORMAL 
  ERROR_LEVEL_EXPERT 
  ERROR_LEVEL_QUIT

Flip

boolean flip();

Blend

float cosEase(float t);
float S(float t);
float cubicEase(float t);
float S5(float t);

Choose

float chooseOne(float[] v);
int chooseOne(int[] v);
int chooseOne(int n);
float chooseOneWeighted(float[] v, float[] w);
int chooseOneWeighted(int[] v, float[] w);

Distance

float dist(int distanceType, float ax, float ay, 
                             float bx, float by, 
                             float px, float py);
dist distanceType: 
  DIST_RADIAL 
  DIST_LINEAR 
  DIST_BOX 
  DIST_PLUS 
  DIST_ANGLE

float distN(int distanceType, int n, float ax, float ay, 
                                     float bx, float by, 
                                     float px, float py); 
distN distanceType:
  DIST_NGON
  DIST_STAR

Ease

float ease(int easeType, float t); 

easeType: 
  EASE_LINEAR
  EASE_IN_CUBIC
  EASE_OUT_CUBIC
  EASE_IN_OUT_CUBIC
  EASE_IN_BACK
  EASE_OUT_BACK
  EASE_IN_OUT_BACK
  EASE_IN_ELASTIC
  EASE_OUT_ELASTIC
  EASE_IN_OUT_ELASTIC
  EASE_CUBIC_ELASTIC
  EASE_ANTICIPATE_CUBIC
  EASE_ANTICIPATE_ELASTIC

Wave

float wave(int waveType, float t, float a);

waveType: 
  WAVE_TRIANGLE
  WAVE_BOX
  WAVE_SAWTOOTH
  WAVE_SINE
  WAVE_COSINE
  WAVE_BLOB
  WAVE_VAR_BLOB
  WAVE_BIAS
  WAVE_GAIN
  WAVE_SYM_BLOB
  WAVE_SYM_VAR_BLOB
  WAVE_SYM_BIAS
  WAVE_SYM_GAIN

AUBaseCurve

float getX(float t);
float getY(float t);
float getZ(float t);
float getIndexValue(float t, int index);

float getTanX(float t);
float getTanY(float t);
float getTanZ(float t);
float getIndexTan(float t, int index);

int getCurveType();
  curve types returned: 
  CRCURVE
  BEZCURVE

void setX(int knotNum, float x);
void setY(int knotNum, float y);
void setZ(int knotNum, float z);
void setXY(int knotNum, float x, float y);
void setXYZ(int knotNum, float x, float y, float z);
void setKnotIndexValue(int knotNum, int index, float value);
void setKnotValues(int knotNum, float[] vals);

void setDensity(float density);
void setClamping(boolean clamp);

AUBezier

AUBezier(float x0, float y0, float x1, float y1,
         float x2, float y2, float x3, float y3);
AUBezier(float x0, float y0, float z0, float x1, float y1, float z1,
         float x2, float y2, float z2, float x3, float y3, float z3);

AUBezier(float[][] knots, int numGeomVals, boolean makeClosed);

AUCamera

AUCamera(PApplet theSketch, int numFrames, 
         int numExposures, boolean saveFrames);

void setNumFrames(int numFrames);
void setNumExposures(int numExposures);
void setAutoNormalize(boolean autoNormalize255);
void setAutoSave(boolean autoSave);
void setAutoExit(boolean autoExit);
void setSaveFormat(String saveFormat);
void setSavePath(String savePath);
void setRampTime(float rampTime);
void setBlendtime(float blendTime);
void setTimeWrap(boolean timeWrap);
void setPreRoll(int preRoll);
void setShutterType(int shutterType);
shutterType: 
  SHUTTER_OPEN
  SHUTTER_UNIFORM
  SHUTTER_BLADE_RIGHT
  SHUTTER_BLADE_LEFT
  SHUTTER_BLADE_DOWN
  SHUTTER_BLADE_UP
  SHUTTER_IRIS

float getTime();
float getFrameTime();

void expose();
void expose(boolean doExpose);

AUCurve

AUCurve(float x0, float y0, float x1, float y1, 
        float x2, float y2, float x3, float y3);
AUCurve(float x0, float y0, float z0, float x1, float y1, float z1, 
        float x2, float y2, float z2, float x3, float y3, float z3);

AUCurve(float[][] knots, int numGeomVals, boolean makeClosed);

AUField

Public variables:
  float[][] z;
  int w, h;    // do not modify w and h

AUField(PApplet theSketch, int wid, int hgt);

void fromPixels(int valueType);
void fromPixels(int valueType, PGraphics pg); 
valueType:
  FIELD_RED
  FIELD_GREEN
  FIELD_BLUE
  FIELD_AVG_RGB
  FIELD_LUM

void flatten(float v);
void setRange(float zmin, float zmax);
void normalize();

void add(float a);
void mul(float a);
void add(AUField f);
void mul(AUField f);

AUField dupe();
void copy(AUField dst);void toPixels(float dx, float dy);

void toPixels(float dx, float dy, AUField mask);
void toPixels(float dx, float dy, AUField mask, float mx, float my);
void toPixels(float dx, float dy, PGraphics pg);
void toPixels(float dx, float dy, AUField mask, PGraphics pg);
void toPixels(float dx, float dy, AUField mask, float mx, float my, PGraphics pg);

AUMultiField

Public variables:
  AUField[] fields;
  int w, h;   // do not modify w and h

AUMultiField(PApplet theSketch, int numFields, int wid, int hgt);

void RGBfromPixels();
void RGBAfromPixels();
void RGBfromPixels(PGraphics pg);
void RGBAfromPixels(PGraphics pg); 

void flattenRGBA(float fr, float fg, float fb, float fa);
void flattenRGB(float fr, float fg, float fb);
void flatten(float v);
void flattenField(int fieldNumber, float v);

void RGBAadd(float fr, float fg, float fb, float fa);
void RGBadd(float fr, float fg, float fb);
void add(float a);
void addField(int fieldNumber, float a);

void RGBAmul(float mr, float mg, float mb, float ma);
void RGBmul(float mr, float mg, float mb);
void mul(float m);
void mulField(int fieldNumber, float m);

void add(AUMultiField mf);
void mul(AUMultiField mf);

AUMultiField dupe();
void copy(AUMultiField dst);
void copyFieldToField(int from, int to);
void swapFields(int a, int b);
void copySeveralFields(int from, int to, int n);
void swapSeveralFields(int a, int b, int n);

void setRangeTogether(float zmin, float zmax, int numFields);
void setRangeSeparate(float zmin, float zmax, int numFields);
void setRangeTogether(float zmin, float zmax);
void setRangeSeparate(float zmin, float zmax);
void normalizeTogether(int numFields);
void normalizeSeparate(int numFields);
void normalizeTogether();
void normalizeSeparate();
void normalizeRGBTogether();
void normalizeRGBSeparate();
void normalizeRGBATogether();
void normalizeRGBASeparate();

void setTriple(int x, int y, float v0, float v1, float v2);
void setQuad(int x, int y, float v0, float v1, float v2, float v3);

void RGBAsetColor(int x, int y, int c);
void RGBsetColor(int x, int y, int c);
int getRGBAColor(int x, int y);
int getRGBColor(int x, int y);

void over(AUMultiField B);
void over(AUMultiField B, AUField mask);

void RGBtoPixels(float dx, float dy);
void RGBAtoPixels(float dx, float dy);
void RGBtoPixels(float dx, float dy, AUField mask);
void RGBtoPixels(float dx, float dy, AUField mask, float mx, float my);
void RGBtoPixels(float dx, float dy, PGraphics pg);
void RGBAtoPixels(float dx, float dy, PGraphics pg);
void RGBtoPixels(float dx, float dy, AUField mask, PGraphics pg);
void RGBtoPixels(float dx, float dy, AUField mask, 
                 float mx, float my, PGraphics pg);

AUShuffle

AUShuffle(float[] v);
AUShuffle(int n);
float next();

AUStepper

AUStepper(float numFrames, float[] stepLengths);
AUStepper(int[] framesPerStep);
AUStepper(int numSteps, int framesPerStep);

void setEases(int[] eases);
void setAllEases(int easeType);

void step();

float getAlfa();
int getStepNum();
float getFullAlfa();

Resources

The library, examples, documentation, and download links are all at the Imaginary Institutes resources page:

https://www.imaginary-institute.com/resources.php

To use it in a sketch, remember to include the library in your program by putting

import AULib.*;

at the top of your code. You can put it there by choosing Sketch>Import Library... and then choosing Andrew's Utilities, or you can type it yourself.