diff --git a/README.md b/README.md index 1683fc4..5aec9d8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # BiomoddLondon -Welcome to the biomodd london 2015 repository +Welcome to the biomodd london 2015 repository -- subtiv try out diff --git a/Sensors/Code/control program/src/main.cpp b/Sensors/Code/control program/src/main.cpp new file mode 100644 index 0000000..e57370b --- /dev/null +++ b/Sensors/Code/control program/src/main.cpp @@ -0,0 +1,13 @@ +#include "ofMain.h" +#include "ofApp.h" + +//======================================================================== +int main( ){ + ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp(new ofApp()); + +} diff --git a/Sensors/Code/control program/src/ofApp.cpp b/Sensors/Code/control program/src/ofApp.cpp new file mode 100644 index 0000000..2709b11 --- /dev/null +++ b/Sensors/Code/control program/src/ofApp.cpp @@ -0,0 +1,320 @@ +#include "ofApp.h" + +//-------------------------------------------------------------- +void ofApp::setup(){ + sensors = new Sensor[3]; + simulate = false; + setBackgroundImage(); + setGUI(); + initArduino(); + failedAttempts = 0; + + // listen for EInitialized notification. this indicates that + // the arduino is ready to receive commands and it is safe to + // call setupArduino() + initArduino(); + ofAddListener(arduino.EInitialized, this, &ofApp::setupArduino); +} + +//-------------------------------------------------------------- +void ofApp::update(){ + arduino.update(); + updateSensors(); +} + +//-------------------------------------------------------------- +void ofApp::draw(){ + ofBackgroundGradient(ofColor::cyan, ofColor::purple); + drawBackgroundImage(); + drawData(); +} + +void ofApp::drawData(){ + ofPushMatrix(); + ofTranslate(ofGetWidth()/4, 0); + for (int i(0); i < 3 ; i++) { + ofTranslate(0, ofGetHeight()/4); + ofDrawBitmapString("sensor"+ofToString(i), -100, -50); + ofPoint prevpoint = ofPoint(0, 0); + for (int x(0); x < sensors[i].averageData.size(); x++) { + ofPoint pt; + pt.x = x * 60; + pt.y = ofMap(sensors[i].averageData[x], 0, 1, -20, 20); + ofDrawCircle(pt, 10); + ofLine(pt, prevpoint); + prevpoint = pt; + } + } + ofPopMatrix(); +} + +//-------------------------------------------------------------- + +void ofApp::setBackgroundImage(){ + img.load("logo.png"); + img.resize(ofGetHeight()/img.getHeight()*img.getWidth(), ofGetHeight()); +} + +void ofApp::drawBackgroundImage(){ + ofPushStyle(); + ofPushMatrix(); + ofSetColor(255,100); + ofTranslate((ofGetWidth()-img.getWidth())/2, (ofGetHeight()-img.getHeight())/2); + img.draw(0,0); + ofPopMatrix(); + ofPopStyle(); +} + + +//-------------------------------------------------------------- +string ofApp::getPostUrl(const unsigned int sensor, const float data){ + string url = SERVER+"/sensors/postSensor?d="; + + url+=ofToString(data); + url+="&s="; + url+=ofToString(sensor); + return url; +} + +float getSimulatedData(){ + return ofRandom(10); +} + +void ofApp::updateSensors(){ + const unsigned int frequency = 100; + int sensor = (int)ofRandom(100)%3; + + // send data + if ((int)ofGetFrameNum()%frequency==0) { + + float data; + + if (simulate) { + arduinoText->setTextString("simulate arduino connection"); + data = getSimulatedData(); + } else { + arduinoText->setTextString("arduino connected"); + data = arduino.getAnalog(sensor); + if (data==FALSE_DATA) { + data = getSimulatedData(); + } + } + + ofHttpResponse resp = ofLoadURL(getPostUrl(sensor, data)); + generalText->setTextString(resp.data); + } + + //receive data + if ((int)ofGetFrameNum()%frequency==floor(frequency/2)) { + const string url = SERVER+"/sensors/getSensors"; + + ofHttpResponse resp = ofLoadURL(url); + generalText->setTextString("data received"); + + ofxJSONElement json; + bool parsingSuccessful = json.parse(resp.data); + + if (parsingSuccessful){ + for (int i(0); i < 3; i++) { + sensors[i].rawData.clear(); + sensors[i].averageData.clear(); + + for (Json::ArrayIndex rd = 0; rd < json[i]["raw"].size(); rd++) { + sensors[i].rawData.push_back(ofToFloat(json[i]["raw"][rd].asString())); + sensors[i].averageData.push_back(ofToFloat(json[i]["averageData"][rd].asString())); + } + } + sensor1->setBuffer(sensors[0].averageData); + sensor2->setBuffer(sensors[1].averageData); + sensor3->setBuffer(sensors[2].averageData); + } else { + ofLogNotice("ofApp::setup") << "Failed to parse JSON" << endl; + } + } + + //update actuators + // actuator 1 + //can be improved by erasing duplication + if (actuator1time > 0) { + int remainingTime = actuator1time-ofGetElapsedTimef(); + if (remainingTime <= 0) { + actuator1time = 0; + arduino.sendDigital(3, ARD_LOW); + actuator1text->setTextString("actuator 1 disabled"); + } else { + actuator1text->setTextString("actuator 1: "+ofToString(remainingTime)+" seconds remaining"); + } + } + + if (actuator2time > 0) { + int remainingTime = actuator2time-ofGetElapsedTimef(); + if (remainingTime <= 0) { + actuator2time = 0; + arduino.sendDigital(4, ARD_LOW); + actuator1text->setTextString("actuator 2 disabled"); + } else { + actuator1text->setTextString("actuator 2: "+ofToString(remainingTime)+" seconds remaining"); + } + } +} + + +void ofApp::initArduino(){ + ofSerial serial; + auto devicelist = serial.getDeviceList(); + + for(auto it(devicelist.begin()); it != devicelist.end(); it++){ + cout << (*it).getDeviceID() << "--" << (*it).getDeviceName() << "--" << (*it).getDevicePath() << endl; + } + + arduino.connect("/dev/cu.usbserial-A9007Lns", 57600); +} + +void ofApp::setupArduino(const int & version){ + if (!arduino.isArduinoReady()){ + ofLogError("arduino connection failure"); + arduinoText->setTextString("arduino initial connection failure"); + } + + //set digital pins + arduino.sendDigitalPinMode(ACTUATOR_1_PIN, ARD_OUTPUT); + arduino.sendDigitalPinMode(ACTUATOR_2_PIN, ARD_OUTPUT); + + //set analog pins + arduino.sendAnalogPinReporting(SENSOR_1_PIN, ARD_ANALOG); + arduino.sendAnalogPinReporting(SENSOR_2_PIN, ARD_ANALOG); + arduino.sendAnalogPinReporting(SENSOR_3_PIN, ARD_ANALOG); +} + +void ofApp::enableActuator(unsigned int nr){ + + + float inittimme = ofGetElapsedTimef(); + if (nr==1) { + arduino.sendDigital(ACTUATOR_1_PIN, ARD_HIGH); + actuator1time = inittimme+ACTUATOR_1_MTIME; + } else { + arduino.sendDigital(ACTUATOR_2_PIN, ARD_HIGH); + actuator2time = inittimme+ACTUATOR_2_MTIME; + } +} + +//-------------------------------------------------------------- +void ofApp::keyPressed(int key){ + switch (key) { + case 'h': + gui->toggleMinified(); + break; + + default: + break; + } + +} + +void ofApp::setGUI(){ + + gui = new ofxUISuperCanvas("BIOMODD LONDON"); + gui->addSpacer(); + gui->addLabel("Press 'h' to Hide GUIs", OFX_UI_FONT_SMALL); + gui->addSpacer(); + gui->addLabel("SERVER"); + gui->addLabel("SENSORS"); + gui->addLabel(""); + gui->addToggle("simulate", simulate); + gui->addLabel(""); + sensor1 = gui->addMovingGraph("SENSOR 1", sensors[0].averageData, DATA_AMNT, 0.0, 1.0); + gui->addTextArea("s1", "SENSOR1"); + sensor2 = gui->addMovingGraph("SENSOR 2", sensors[1].averageData, DATA_AMNT, 0.0, 1.0); + gui->addTextArea("s1", "SENSOR2"); + sensor3 = gui->addMovingGraph("SENSOR 3", sensors[2].averageData, DATA_AMNT, 0.0, 1.0); + gui->addTextArea("s1", "SENSOR3"); + + gui->addLabel(""); + gui->addLabelButton("enable actuator 1", false); + actuator1text = gui->addTextArea("", "actuator 1 disabled"); + + gui->addLabel(""); + gui->addLabelButton("enable actuator 2", false); + actuator2text = gui->addTextArea("", "actuator 2 disabled"); + + gui->addSpacer(); + gui->addLabel(""); + gui->addLabel("GAME"); + + gui->addLabel(""); + gui->addLabel("ARDUINO"); + arduinoText = gui->addTextArea("ArduinoText", "arduino running"); + + gui->addLabel(""); + gui->addSpacer(); + generalText = gui->addTextArea("generalTextt", "general information display will occur here"); + + + gui->autoSizeToFitWidgets(); + ofAddListener(gui->newGUIEvent,this,&ofApp::guiEvent); +} + +void ofApp::guiEvent(ofxUIEventArgs &e){ + string name = e.getName(); + int kind = e.getKind(); + + if (name=="simulate") { + simulate = ((ofxUIToggle *)e.widget)->getValue(); + } else if (name == "enable actuator 1"){ + enableActuator(1); + } else if (name == "enable actuator 2"){ + enableActuator(2); + } + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseEntered(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseExited(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void ofApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void ofApp::dragEvent(ofDragInfo dragInfo){ + +} diff --git a/Sensors/Code/control program/src/ofApp.h b/Sensors/Code/control program/src/ofApp.h new file mode 100644 index 0000000..0ba2dd9 --- /dev/null +++ b/Sensors/Code/control program/src/ofApp.h @@ -0,0 +1,87 @@ +#pragma once + +#include "ofMain.h" +#include "ofxJSON.h" +#include "ofxUI.h" + +#define DATA_AMNT 10 +#define ACTUATOR_1_MTIME 25 +#define ACTUATOR_2_MTIME 25 + +#define ACTUATOR_1_PIN 3 +#define ACTUATOR_2_PIN 4 + +#define SENSOR_1_PIN 0 +#define SENSOR_2_PIN 1 +#define SENSOR_3_PIN 2 + +#define FALSE_DATA -1 + + + + + +struct Sensor { + Sensor(){ + for (int i(0); i < DATA_AMNT; i++){ + rawData.push_back(0); + averageData.push_back(0); + } + } + + vector rawData; + vector averageData; +}; + +class ofApp : public ofBaseApp{ + + public: + void setup(); + void update(); + void draw(); + + void keyPressed(int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void mouseEntered(int x, int y); + void mouseExited(int x, int y); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + void urlResponse(ofHttpResponse & response); + void guiEvent(ofxUIEventArgs &e); + void setGUI(); + + void setBackgroundImage(); + string getPostUrl(const unsigned int sensor, const float data); + void updateSensors(); + void drawBackgroundImage(); + void drawData(); + void initArduino(); + void setupArduino(const int & version); + void enableActuator(unsigned int nr); + + + + Sensor * sensors; + ofImage img; + ofxUISuperCanvas *gui; + ofxUIMovingGraph *sensor1; + ofxUIMovingGraph *sensor2; + ofxUIMovingGraph *sensor3; + ofxUITextArea *arduinoText; + ofxUITextArea *generalText; + unsigned int failedAttempts; + ofArduino arduino; + int actuator1time; + int actuator2time; + ofxUITextArea *actuator1text; + ofxUITextArea *actuator2text; + bool simulate; + + const string SERVER = "http://localhost:3000"; +}; diff --git a/Sensors/Code/readSensor/readSensor.ino b/Sensors/Code/readSensor/readSensor.ino new file mode 100644 index 0000000..57d546b --- /dev/null +++ b/Sensors/Code/readSensor/readSensor.ino @@ -0,0 +1,13 @@ +int LDR_PIN = A0; + +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); +} + +void loop() { + // put your main code here, to run repeatedly: + int readp = analogRead(LDR_PIN); + Serial.println(readp); + +} diff --git a/Sensors/Hardware/designBiomoddLondonSensors.fzz b/Sensors/Hardware/designBiomoddLondonSensors.fzz new file mode 100644 index 0000000..bb2d12d Binary files /dev/null and b/Sensors/Hardware/designBiomoddLondonSensors.fzz differ diff --git a/Sensors/Hardware/designBiomoddLondonSensors_bb.png b/Sensors/Hardware/designBiomoddLondonSensors_bb.png new file mode 100644 index 0000000..5913466 Binary files /dev/null and b/Sensors/Hardware/designBiomoddLondonSensors_bb.png differ diff --git a/code.js b/code.js index 1c053a9..b313210 100644 --- a/code.js +++ b/code.js @@ -1,10 +1,787 @@ -function setup() { - // uncomment this line to make the canvas the full size of the window - var myCanvas = createCanvas(600, 400); - myCanvas.parent('myContainer'); + + +/** + * Our actual sketch + * @param {p5} p P5 reference + * @return {} nothing + */ + s = function( p ) { + + +//---------------------------------- +// variables +//---------------------------------- +// + +//change this to your own playername; + this.playername = "SUBTIV"; + +/** + * Background: The background color for our sketch, can be modified + * @type {String} + * @namespace changeable variables + */ + //----- COLORS ------------------ + this.backgroundColor = '#660066'; //rgb(102, 0, 102) + this.sensorColor = 'pink'; + this.gridColor = p.color(255, 200, 0, 50); + this.avatarCircleColor = 'white'; + this.avatarRecentColor = 'black'; + this.historyColor = 'white'; + + //----- SIZES ------------------ + //the width of the sensor line + this.sensorWidth = 3; + + //the width of the grid line + this.gridWidth = 1; + + // the radius of the avatar circle +this.avatarCircleWidth = 15; + +//the circles at the corners of the history lines +this.historyCircleSize = 35; + +// the width of the history lines +this.historyLineWidth = 1; + + + + +//----- TEXT ------------------ +this.deadText = "WINNER"; +this.winnerText = " † DEAD †"; + +//----- SENSORS ------------------ +/** + * Sensorlength is a variable that sets the length of the + * the sensors-graph in game so: width/sensorLength; + * @type {Number} + */ + this.sensorLength = 4; + +/** + * SensorHeigth is a variable that sets the height of the sensors-graph + * in game so: height/sensorHeight; + * @type {Number} + */ + this.sensorHeigth = 20; + + +//---------------------------------- +// game variables +//---------------------------------- +// modifying these will change the game +// behavior + +/** + * The desired framerate + * @type {Number} + */ + this.fps = 10; + +/** + * The grid is the amount of points that makes up the game field + * So we have 100 (x) * 100 (y) points + * @type {Number} + */ + this.grid_size = 100; + +/** + * The avatar, the player, you. + */ + this.avatar; + + /** + * Additional object for storying other players history-lines + */ + this.playerhistory; + + this.serverupdatepf = 30; + + this.serverURL = 'http://biomoddlondon-sead.rhcloud.com/'; + + this.sensors = []; + + + +//---------------------------------- +// MAIN GAME FUNCTIONS +//---------------------------------- + // ---- setup ---------------------- + // will be executed once | at the beginning + p.setup = function() { + myCanvas = p.createCanvas(p.windowWidth, p.windowHeight); + myCanvas.parent('myContainer'); + + //set the framerate + p.frameRate(fps); + avatar = Avatar(); + playerhistory = Playerhistory(); + killAvatarServer(); + getData(); + }; + + // ---- draw ---------------------- + // will be executed every frame + // use this for updating and drawing + p.draw = function() { + if (p.frameCount%this.serverupdatepf==0){ + getData(); + } + + // -- update + avatar.update(); + + if (avatar.checkTurned()){ + playerhistory.set(this.playername, avatar.history); + sendHistory(); // send to server + + } + + if (playerhistory.checkBump(avatar.position)){ + avatar.kill(); + } + + // -- draw + p.background(backgroundColor); + drawGrid(); + drawSensors(); + playerhistory.draw(); + avatar.draw(); + + var txt = ""; + p.textSize(100); + if(playerhistory.winner()&&avatar.alive()){ + txt = this.deadText; + } else if (!avatar.alive()) { + txt = this.winnerText; + } + var twidth = p.textWidth(txt); + p.text(txt, (p.width-twidth)/2, p.height/12); +}; + + +//---------------------------------- +// SERVER FUNCTIONS +//---------------------------------- +this.callAPI = function(path, callback, params){ + if(!params){ + params = {}; + } + p.httpGet(this.serverURL+path, params, 'jsonp', callback); +} + +function optimiseData(data){ + delete data.responseText; +} + +this.getData = function(){ + callAPI("sensor/getSensors", function(data){ + optimiseData(data); + this.sensors = data; + }) +} + +this.sendHistory = function(){ + callAPI("game/updateHistory", function(data){ + optimiseData(data); + for (var i = data.length - 1; i >= 0; i--) { + if (data[i].name !== this.playername){ + this.playerhistory.set(data[i].name, data[i].data); + } + }; + }, {n: this.playername, d: this.avatar.history}); +} + +this.killAvatarServer = function(){ + callAPI("game/kill", function(data){}, {n:this.playername}); +} + + +//---------------------------------- +// SENSOR FUNCTIONS +//---------------------------------- +this.drawSensors = function(){ + var beginy = p.height/4; + var offset = p.height/this.sensorHeigth; + var offsetx = p.width/this.sensorLength; + var prevpoint = {}; + + if(p.frameCount%3==0){ + return; + } + + p.noFill(); + p.stroke(this.sensorColor); + p.strokeWeight(this.sensorWidth); + + p.push(); + for (var i = this.sensors.length - 1; i >= 0; i--) { + var data = this.sensors[i].averageData; + p.beginShape(); + for (var d = data.length - 1; d >= 0; d--) { + var x = offsetx + d/data.length*(p.width - offsetx*2); + var y = beginy + data[d]*offset; + p.vertex(x, y); + + //check for bump with avatar + var newpoint = makePoint(x,y); + + if (d < data.length-1){ + if (pointOnLine(world2grid(prevpoint), world2grid(newpoint), this.avatar.position)){ + this.avatar.kill(); + } + } + + prevpoint = newpoint; + + }; + p.endShape(); + beginy+=p.height/4; + } + p.pop(); +} + + + + +//---------------------------------- +// I/O FUNCTIONS +//---------------------------------- +// gets called everytime we press the keyboard +p.keyPressed = function() { + switch (p.key) { + case "W": + avatar.move(true); + break; + case "X": + avatar.move(false); + break; + case "R": //'r' + globalReset(); + killAvatarServer(); + break; + } +} + + + +//---------------------------------- +// WORLD FUNCTIONS +//---------------------------------- + + /** + * Drawgrid draws the grid function over the world + * so when our [grid_size = 100] it will draw 10.000 lines + * @return {} returns nothing + */ + this.drawGrid = function(){ + var gridColor = this.gridColor; + + p.push(); + p.noFill(); + p.strokeWeight(this.gridWidth); + p.stroke(gridColor); + + //loop: goes from x=0 -> x=grid_size + for (var x = 0; x < grid_size; x++){ + var worldpoint = grid2world(makePoint(x,x)); + // draws the vertical lines + p.line(worldpoint.x, 0, worldpoint.x, p.height); + // draws the horizontal lines + p.line(0, worldpoint.y, p.width, worldpoint.y); + } + + p.pop(); } -function draw() { - // draw stuff here - ellipse(width/2, height/2, 100, 50); -} \ No newline at end of file +//---------------------------------- +// AVATAR FUNCTIONS +//---------------------------------- +/** + * Constructs a new avatar + * + * @class Avatar + * @classdesc The player instance + */ + this.Avatar = function(){ + + // ---- public ---------------------- + // -------- methods ----------------- + /** + * Initializes the avatar + * (private) + * @return {} returns nothing + */ + var init = function(){ + reset(); + } + + /** + * resets the avatar + */ + var reset = function(){ + + function makeRandomGrid(){ + var offset = grid_size/4; + return p.random(offset, grid_size-offset); + } + + //set members + position = makePoint(makeRandomGrid(), makeRandomGrid()); + orientation = p.floor(p.random(100)%8); + speed = 1; + alive = true; + history = []; + + updateHistory(); + + } + + /** + * updates the avatar location + * @return {} nothing + */ + var update = function(){ + if (!alive){ return; } + + /** + * Updates the location based on the orientation + */ + function updateOrientation(){ + switch (orientation) { + case 0: + position.y-=speed; + break; + case 1: + position.x+=speed; + position.y-=speed; + break; + case 2: + position.x+=speed; + break; + case 3: + position.x+=speed; + position.y+=speed; + break; + case 4: + position.y+=speed; + break; + case 5: + position.x-=speed; + position.y+=speed; + break; + case 6: + position.x-=speed; + break; + case 7: + position.x-=speed; + position.y-=speed; + break; + default: + console.log("wrong position"); + break; + } + } + + /** + * Checks wether the avatar has hit the borders + */ + var checkBorders = function(){ + if ((position.x <= 0) || (position.x >= grid_size) || (position.y <= 0) || (position.y >= grid_size)){ + updateHistory(); + alive = false; + } + } + + // call our 2 functions to perform the update + updateOrientation(); + checkBorders(); + } + + /** + * draws the actual avatar + * @return {} returns nothing + */ + var draw = function(){ + var circleSize = avatarCircleWidth; + p.push(); + p.stroke(avatarCircleColor); + p.noFill(); + var ppos = makePoint(Math.floor(position.x),Math.floor(position.y)); + var worldpoint = grid2world(ppos); + circle(worldpoint, circleSize); + p.stroke(avatarRecentColor); + lineFromPoints(worldpoint, grid2world(getLastPoint())); + p.pop(); + } + + /** + * changes the orienation of the avatar, + * gets called when a key is pressed + * @param {Bool} left set to "true" if you want + * to turn left + * @return {} returns nothing + */ + var move = function(left){ + left? orientation--: orientation++; + + if (orientation<0){ + orientation = 7; + } else if (orientation > 7){ + orientation = 0; + } + + updateHistory(); + } + + /** + * Check if the avatar has turned, + * so we can update our location to the + * server and so on. + * @return {Bool} returns true if + * we have turned. + */ + var checkTurned = function(){ + var rv = hasturned; + hasturned = false; + return rv; + } + + var kill = function(){ + killAvatarServer(); + alive = false; + } + + // -------- public members ----------------- + /** + * The grid position of the avatar + * @type {Point} + */ + var position; + + var hasturned; + + /** + * boolean value to check wether the avatar is alive + * @type {Bool} + */ + var alive; + + /** + * Array of Points of the avatars earlier locations + * @type {Array} + */ + var history = []; + + // ---- private ---------------------- + + /** + * Auxiliary function that gets called + * when we have turned + * (private) + * @return {} returns nothing + */ + function updateHistory(){ + hasturned = true; + history.push(makePoint(Math.floor(position.x), Math.floor(position.y))); + } + + /** + * Gets the last point of our own history + * (private) + * @return {Point} A point object + */ + function getLastPoint(){ + return history.last(); + } + + // -------- private members ----------------- + + /** + * The orientation of the avatar which is one of 8 numbers + * C bottom sketch for more information + * (private) + * @type {Number} + */ + var orientation; + + /** + * The progressing speed of the avatar + * (private) + * @type {Number} + */ + var speed; + + + // ---- init ------------------------ + init(); + + // ---- return ---------------------- + return { + reset : reset, + draw : draw, + update: update, + kill: kill, + checkTurned: checkTurned, + position: position, + history: history, + move: move, + alive: function(){return alive;} + } +} + + +//---------------------------------- +// PLAYERSHISTORY FUNCTIONS +//---------------------------------- +/** + * Constructs a new Playerhistory + * + * @class Playerhistory + * @classdesc datastructure that maintains + * all of the history lines of the players + */ + + this.Playerhistory = function(){ + // ---- public ---------------------- + + // -------- methods ----------------- + /** + * resets the object + */ + var reset = function(){ + memberlines = {}; + } + + /** + * updates a specific players history + * (could be highly modified) + * @param {string} name the name of the player + * @param {Array} pts an array of points + */ + var set = function(name, pts){ + memberlines.name = pts; + } + + /** + * draws all of the players history + */ + var draw = function(){ + + for (var member in memberlines){ + p.push(); + p.noFill(); + p.strokeWeight(historyLineWidth); + p.stroke(historyColor); + + var currentLine = memberlines[member]; + + p.beginShape(); + + for (var idx = 0, len = currentLine.length; idx < len; idx++){ + var pt = currentLine[idx]; + vertexFromPoint(grid2world(currentLine[idx])); + circle(grid2world(currentLine[idx]), historyCircleSize); + } + p.endShape(); + + p.pop(); + } + } + + this.winner = function(){ + return (Object.keys(memberlines).length == 1); + } + + /** + * checks wether the point bumps into any of the lines + * @param {Point} pt the point we're checking + */ + var checkBump = function(pt){ + + for (var member in memberlines){ + + var currentLine = memberlines[member]; + + if (currentLine.length > 1){ + for (var idx = 1, len = currentLine.length; idx < len; idx++){ + if (pointOnLine(currentLine[idx-1], currentLine[idx], pt)){ + return true; + } + } + } + } + return false; + } + + // -------- properties -------------- + + /// ---- private -------------------- + function init(){ + reset(); + } + + // -------- methods ----------------- + // -------- properties -------------- + var memberlines = {}; + + /// ---- init ----------------------- + init(); + + /// ---- return --------------------- + return { + reset : reset, + set : set, + draw: draw, + checkBump: checkBump, + winner: winner + } +} + +//---------------------------------- +// AUX FUNCTIONS +//---------------------------------- +//makes an object containing x and y coordinates +/** + * makePoint : makes an Point object containing x and y coordinates + * @param {number} x + * @param {number} y + * @return {Point} + * @namespace functions + * */ + var makePoint = function(x, y){ + (x == null)? x = 0 : x=x; + (y == null)? y = 0 : y=y; + return {x: x, y: y}; +} + +/** + * world2grid : Remaps a point from the world (screensize) to the grid + * @param {Point} pt the original point + * @return {Point} the remapped point + * @namespace functions + */ + function world2grid(pt){ + return makePoint(Math.floor(pt.x / p.width * grid_size), Math.floor(pt.y / p.height * grid_size)); +} + +/** + * grid2world : Remaps a point from the grid to the world (screensize) + * @param {Point} pt the original point + * @return {Point} the remapped point + * @namespace functions + */ + function grid2world(pt){ + return makePoint(Math.floor(pt.x * p.width / grid_size), Math.floor(pt.y * p.height / grid_size)); +} + +/** + * lineFromPoints : draws a line between two points + * @param {Point} p1 + * @param {Point} p2 + * @namespace functions + */ + function lineFromPoints(p1, p2){ + p.line(p1.x, p1.y, p2.x, p2.y); +} + +/** + * circle: draws a circle using a point + * @param {Point} pt the center of the circle + * @param {Number} radius the radius of the point + * @namespace functions + */ + function circle(pt, radius){ + p.ellipse(pt.x, pt.y, radius, radius); +} + +/** + * vertexFromPoint: draws a vertex from a Point object + * @param {Point} pt the point we're adding to the shape + * @namespace functions + */ + function vertexFromPoint(pt){ + p.vertex(pt.x, pt.y); +} + + // returns true if point lies on the line + // http://stackoverflow.com/questions/11907947/how-to-check-if-a-point-lies-on-a-line-between-2-other-points + /** + * checks wether a point lays on the line between + * two other points + * @param {Point} p1 the first point of the line + * @param {Point} p2 the second point of the line + * @param {Point} currp the point we're checking + * @return {Bool} returns true if the point lays on the line + * @namespace functions + */ + function pointOnLine(p1, p2, currp){ + + p1 = makePoint(Math.floor(p1.x),Math.floor(p1.y)); + p2 = makePoint(Math.floor(p2.x),Math.floor(p2.y)); + currp = makePoint(Math.floor(currp.x),Math.floor(currp.y)); + + var dxc = currp.x - p1.x; + var dyc = currp.y - p1.y; + + var dxl = p2.x - p1.x; + var dyl = p2.y - p1.y; + + var cross = p.floor(dxc * dyl - dyc * dxl); + + // check if point lays on line (not necessarily between the two outer points) + if (cross !== 0){ return false; } + var rval; + if (p.abs(dxl) >= p.abs(dyl)){ + rval = (dxl > 0) ? ((p1.x <= currp.x) && (currp.x <= p2.x )) : ((p2.x <= currp.x) && (currp.x <= p1.x )); + } else { + rval= (dyl > 0) ? ((p1.y <= currp.y) && (currp.y <= p2.y )) : ((p2.y <= currp.y) && (currp.y <= p1.y )); + } + return rval; + } + + if (!Array.prototype.last){ + Array.prototype.last = function(){ + return this[this.length - 1]; + }; + }; + }; + + var globalReset = function(){ + if(myp5){ + myp5.remove(); + myp5.canvas.remove(); + } + + myp5 = new p5(s); + } + + globalReset(); + + + + + +//---------------------------------- +// NOTES +//---------------------------------- +// +--------------------------+ + // | 0 | + // | 7 + | + // | X | XX 1 | + // | XXX | XX | + // | XXX |XXXX | + // | 6 +--------------+ 2 | + // | XX|XXXXX | + // | XXX | XX | + // | XX | X | + // | X + 3 | + // | 5 4 | + // | | + // +--------------------------+ + // This is how our orientation works + // orientation is a number representing + // a direction in which the avatar is going + // for example "0" means going straight up diff --git a/index.html b/index.html new file mode 100644 index 0000000..d6999c8 --- /dev/null +++ b/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/js/initialSketch.js b/js/initialSketch.js new file mode 100644 index 0000000..f5e7708 --- /dev/null +++ b/js/initialSketch.js @@ -0,0 +1,2 @@ +var s = null; +var myp5 = null; \ No newline at end of file diff --git a/js/p5.min.js b/js/p5.min.js new file mode 100644 index 0000000..7efdd8e --- /dev/null +++ b/js/p5.min.js @@ -0,0 +1,7 @@ +/*! p5.js v0.4.6 June 24, 2015 */!function(a,b){"function"==typeof define&&define.amd?define("p5",[],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.p5=b()}(this,function(){var amdclean={};return amdclean.core_shim=function(a){window.requestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a,b){window.setTimeout(a,1e3/60)}}(),window.performance=window.performance||{},window.performance.now=function(){var a=Date.now();return window.performance.now||window.performance.mozNow||window.performance.msNow||window.performance.oNow||window.performance.webkitNow||function(){return Date.now()-a}}(),function(){"use strict";"undefined"!=typeof Uint8ClampedArray&&(Uint8ClampedArray.prototype.slice=Array.prototype.slice)}()}({}),amdclean.core_constants=function(a){var b=Math.PI;return{P2D:"p2d",WEBGL:"webgl",ARROW:"default",CROSS:"crosshair",HAND:"pointer",MOVE:"move",TEXT:"text",WAIT:"wait",HALF_PI:b/2,PI:b,QUARTER_PI:b/4,TAU:2*b,TWO_PI:2*b,DEGREES:"degrees",RADIANS:"radians",CORNER:"corner",CORNERS:"corners",RADIUS:"radius",RIGHT:"right",LEFT:"left",CENTER:"center",TOP:"top",BOTTOM:"bottom",BASELINE:"alphabetic",POINTS:"points",LINES:"lines",TRIANGLES:"triangles",TRIANGLE_FAN:"triangles_fan",TRIANGLE_STRIP:"triangles_strip",QUADS:"quads",QUAD_STRIP:"quad_strip",CLOSE:"close",OPEN:"open",CHORD:"chord",PIE:"pie",PROJECT:"square",SQUARE:"butt",ROUND:"round",BEVEL:"bevel",MITER:"miter",RGB:"rgb",HSB:"hsb",HSL:"hsl",AUTO:"auto",ALT:18,BACKSPACE:8,CONTROL:17,DELETE:46,DOWN_ARROW:40,ENTER:13,ESCAPE:27,LEFT_ARROW:37,OPTION:18,RETURN:13,RIGHT_ARROW:39,SHIFT:16,TAB:9,UP_ARROW:38,BLEND:"normal",ADD:"lighter",DARKEST:"darken",LIGHTEST:"lighten",DIFFERENCE:"difference",EXCLUSION:"exclusion",MULTIPLY:"multiply",SCREEN:"screen",REPLACE:"source-over",OVERLAY:"overlay",HARD_LIGHT:"hard-light",SOFT_LIGHT:"soft-light",DODGE:"color-dodge",BURN:"color-burn",THRESHOLD:"threshold",GRAY:"gray",OPAQUE:"opaque",INVERT:"invert",POSTERIZE:"posterize",DILATE:"dilate",ERODE:"erode",BLUR:"blur",NORMAL:"normal",ITALIC:"italic",BOLD:"bold",_DEFAULT_TEXT_FILL:"#000000",_DEFAULT_LEADMULT:1.25,_CTX_MIDDLE:"middle",LINEAR:"linear",QUADRATIC:"quadratic",BEZIER:"bezier",CURVE:"curve",_DEFAULT_STROKE:"#000000",_DEFAULT_FILL:"#FFFFFF"}}({}),amdclean.core_core=function(a,b,c){"use strict";var d=c,e=function(a,b,c){2===arguments.length&&"boolean"==typeof b&&(c=b,b=void 0),this._setupDone=!1,this.pixelDensity=window.devicePixelRatio||1,this._userNode=b,this._curElement=null,this._elements=[],this._preloadCount=0,this._updateInterval=0,this._isGlobal=!1,this._loop=!0,this._styles=[],this._defaultCanvasSize={width:100,height:100},this._events={mousemove:null,mousedown:null,mouseup:null,click:null,mouseover:null,mouseout:null,keydown:null,keyup:null,keypress:null,touchstart:null,touchmove:null,touchend:null,resize:null,blur:null},window.DeviceOrientationEvent?this._events.deviceorientation=null:window.DeviceMotionEvent?this._events.devicemotion=null:this._events.MozOrientation=null,/Firefox/i.test(navigator.userAgent)?this._events.DOMMouseScroll=null:this._events.mousewheel=null,this._loadingScreenId="p5_loading",this._start=function(){if(this._userNode&&"string"==typeof this._userNode&&(this._userNode=document.getElementById(this._userNode)),this._loadingScreen=document.getElementById(this._loadingScreenId),!this._loadingScreen){this._loadingScreen=document.createElement("loadingDiv"),this._loadingScreen.innerHTML="loading...",this._loadingScreen.style.position="absolute";var a=this._userNode||document.body;a.appendChild(this._loadingScreen)}this.createCanvas(this._defaultCanvasSize.width,this._defaultCanvasSize.height,"p2d",!0);var b=this.preload||window.preload,c=this._isGlobal?window:this;b?(this._preloadMethods.forEach(function(a){c[a]=function(){var b=Array.prototype.slice.call(arguments);return c._preload(a,b)}}),b(),0===this._preloadCount&&(this._setup(),this._runFrames(),this._draw())):(this._setup(),this._runFrames(),this._draw())}.bind(this),this._preload=function(a,b){var c=this._isGlobal?window:this;c._setProperty("_preloadCount",c._preloadCount+1);var d=function(a){c._setProperty("_preloadCount",c._preloadCount-1),0===c._preloadCount&&(c._setup(),c._runFrames(),c._draw())};return b.push(d),e.prototype[a].apply(c,b)}.bind(this),this._setup=function(){var a=this._isGlobal?window:this;"function"==typeof a.preload&&this._preloadMethods.forEach(function(b){a[b]=e.prototype[b]}),"function"==typeof a.setup&&a.setup();for(var b=new RegExp(/(^|\s)p5_hidden(?!\S)/g),c=document.getElementsByClassName("p5_hidden"),d=0;d=c-d)&&(this._setProperty("frameCount",this.frameCount+1),this.redraw(),this._updatePAccelerations(),this._updatePMouseCoords(),this._updatePTouchCoords(),this._frameRate=1e3/(a-this._lastFrameTime),this._lastFrameTime=a),this._loop&&window.requestAnimationFrame(this._draw)}.bind(this),this._runFrames=function(){this._updateInterval&&clearInterval(this._updateInterval)}.bind(this),this._setProperty=function(a,b){this[a]=b,this._isGlobal&&(window[a]=b)}.bind(this),this.remove=function(){if(this._curElement){this._loop=!1,this._updateInterval&&clearTimeout(this._updateInterval);for(var a in this._events)window.removeEventListener(a,this._events[a]);for(var b=0;bc&&(c+=1),c>1&&(c-=1)}return[Math.round(360*c),Math.round(100*d),Math.round(100*l),1*h]},c.ColorUtils.hslaToRGBA=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3]||b[3];c/=b[0],d/=b[1],e/=b[2],f/=b[3];var g=[];if(0===d)g=[Math.round(255*e),Math.round(255*e),Math.round(255*e),f];else{var h,i,j,k,l;i=.5>e?e*(1+d):e+d-d*e,h=2*e-i;var m=function(a,b,c){return 0>c?c+=1:c>1&&(c-=1),1>6*c?a+6*(b-a)*c:1>2*c?b:2>3*c?a+(b-a)*(2/3-c)*6:a};j=m(h,i,c+1/3),k=m(h,i,c),l=m(h,i,c-1/3),g=[Math.round(255*j),Math.round(255*k),Math.round(255*l),Math.round(255*f)]}return g},c.ColorUtils.rgbaToHSLA=function(a,b){var c,d,e,f,g,h=a[0]/b[0],i=a[1]/b[1],j=a[2]/b[2],k=a[3]/b[3],l=Math.min(h,i,j),m=Math.max(h,i,j),n=m-l,o=(m+l)/2;return 0===n?(c=0,d=0):(e=((m-h)/6+n/2)/n,f=((m-i)/6+n/2)/n,g=((m-j)/6+n/2)/n,h===m?c=g-f:i===m?c=1/3+e-g:j===m&&(c=2/3+f-e),0>c&&(c+=1),c>1&&(c-=1),d=.5>o?n/(m+l):n/(2-m-l)),[Math.round(360*c),Math.round(100*d),Math.round(100*o),1*k]},c.ColorUtils}({},amdclean.core_core),amdclean.color_p5Color=function(a,b,c,d){var e=b,f=c,g=d;e.Color=function(a,b){this.maxArr=a._colorMaxes[a._colorMode],this.color_array=e.Color._getFormattedColor.apply(a,b);var c=a._colorMode===g.HSB,d=a._colorMode===g.RGB,h=a._colorMode===g.HSL;if(d)this.rgba=this.color_array;else if(h)this.hsla=this.color_array,this.rgba=f.hslaToRGBA(this.color_array,this.maxArr);else{if(!c)throw new Error(a._colorMode+"is an invalid colorMode.");this.hsba=this.color_array,this.rgba=f.hsbaToRGBA(this.color_array,this.maxArr)}return this},e.Color.prototype.getHue=function(){return this.hsla||this.hsba?this.hsla?this.hsla[0]:this.hsba[0]:(this.hsla=f.rgbaToHSLA(this.color_array,this.maxArr),this.hsla[0])},e.Color.prototype.getSaturation=function(){return this.hsla?this.hsla[1]:this.hsba?this.hsba[1]:(this.hsla=f.rgbaToHSLA(this.color_array,this.maxArr),this.hsla[1])},e.Color.prototype.getBrightness=function(){return this.hsba?this.hsba[2]:(this.hsba=f.rgbaToHSBA(this.color_array,this.maxArr),this.hsba[2])},e.Color.prototype.getLightness=function(){return this.hsla?this.hsla[2]:(this.hsla=f.rgbaToHSLA(this.color_array,this.maxArr),this.hsla[2])},e.Color.prototype.getRed=function(){return this.rgba[0]},e.Color.prototype.getGreen=function(){return this.rgba[1]},e.Color.prototype.getBlue=function(){return this.rgba[2]},e.Color.prototype.getAlpha=function(){return this.hsba||this.hsla?this.hsla?this.hsla[3]:this.hsba[3]:this.rgba[3]},e.Color.prototype.toString=function(){for(var a=this.rgba,b=0;3>b;b++)a[b]=Math.floor(a[b]);var c="undefined"!=typeof a[3]?a[3]/255:1;return"rgba("+a[0]+","+a[1]+","+a[2]+","+c+")"};var h=/\s*/,i=/(\d{1,3})/,j=/((?:\d+(?:\.\d+)?)|(?:\.\d+))/,k=new RegExp(j.source+"%"),l={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},m={HEX3:/^#([a-f0-9])([a-f0-9])([a-f0-9])$/i,HEX6:/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i,RGB:new RegExp(["^rgb\\(",i.source,",",i.source,",",i.source,"\\)$"].join(h.source),"i"),RGB_PERCENT:new RegExp(["^rgb\\(",k.source,",",k.source,",",k.source,"\\)$"].join(h.source),"i"),RGBA:new RegExp(["^rgba\\(",i.source,",",i.source,",",i.source,",",j.source,"\\)$"].join(h.source),"i"),RGBA_PERCENT:new RegExp(["^rgba\\(",k.source,",",k.source,",",k.source,",",j.source,"\\)$"].join(h.source),"i"),HSL:new RegExp(["^hsl\\(",i.source,",",k.source,",",k.source,"\\)$"].join(h.source),"i"),HSLA:new RegExp(["^hsla\\(",i.source,",",k.source,",",k.source,",",j.source,"\\)$"].join(h.source),"i")};return e.Color._getFormattedColor=function(){var a,b,c,d,f,h,i=arguments.length,j=this._colorMode;if(i>=3)a=arguments[0],b=arguments[1],c=arguments[2],d="number"==typeof arguments[3]?arguments[3]:this._colorMaxes[j][3];else{if(1===i&&"string"==typeof arguments[0])return f=arguments[0].trim().toLowerCase(),l[f]?e.Color._getFormattedColor.apply(this,[l[f]]):(h=m.HEX3.test(f)?m.HEX3.exec(f).slice(1).map(function(a){return parseInt(a+a,16)}):m.HEX6.test(f)?m.HEX6.exec(f).slice(1).map(function(a){return parseInt(a,16)}):m.RGB.test(f)?m.RGB.exec(f).slice(1).map(function(a){return parseInt(a,10)}):m.RGB_PERCENT.test(f)?m.RGB_PERCENT.exec(f).slice(1).map(function(a){return parseInt(parseFloat(a)/100*255,10)}):m.RGBA.test(f)?m.RGBA.exec(f).slice(1).map(function(a,b){return 3===b?parseInt(255*parseFloat(a),10):parseInt(a,10)}):m.RGBA_PERCENT.test(f)?m.RGBA_PERCENT.exec(f).slice(1).map(function(a,b){return 3===b?parseInt(255*parseFloat(a),10):parseInt(parseFloat(a)/100*255,10)}):m.HSL.test(f)?m.HSL.exec(f).slice(1).map(function(a){return parseInt(a,10)}):m.HSLA.test(f)?m.HSLA.exec(f).slice(1).map(function(a){return parseFloat(a,10)}):[255],e.Color._getFormattedColor.apply(this,h));if(1===i&&"number"==typeof arguments[0])j===g.RGB?a=b=c=arguments[0]:(j===g.HSB||j===g.HSL)&&(a=c=arguments[0],b=0),d="number"==typeof arguments[1]?arguments[1]:this._colorMaxes[j][3];else{if(2!==i||"number"!=typeof arguments[0]||"number"!=typeof arguments[1])throw new Error(arguments+"is not a valid color representation.");j===g.RGB?a=b=c=arguments[0]:(j===g.HSB||j===g.HSL)&&(a=c=arguments[0],b=0),d=arguments[1]}}return[a,b,c,d]},e.Color}({},amdclean.core_core,amdclean.color_color_utils,amdclean.core_constants),amdclean.core_p5Element=function(a,b){function c(a,b,c){var d=b.bind(c);c.elt.addEventListener(a,d,!1),c._events[a]=d}var d=b;return d.Element=function(a,b){this.elt=a,this._pInst=b,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight},d.Element.prototype.parent=function(a){return"string"==typeof a?a=document.getElementById(a):a instanceof d.Element&&(a=a.elt),a.appendChild(this.elt),this},d.Element.prototype.id=function(a){return this.elt.id=a,this},d.Element.prototype["class"]=function(a){return this.elt.className+=" "+a,this},d.Element.prototype.mousePressed=function(a){return c("mousedown",a,this),c("touchstart",a,this),this},d.Element.prototype.mouseWheel=function(a){return c("mousewheel",a,this),this},d.Element.prototype.mouseReleased=function(a){return c("mouseup",a,this),c("touchend",a,this),this},d.Element.prototype.mouseClicked=function(a){return c("click",a,this),this},d.Element.prototype.mouseMoved=function(a){return c("mousemove",a,this),c("touchmove",a,this),this},d.Element.prototype.mouseOver=function(a){return c("mouseover",a,this),this},d.Element.prototype.mouseOut=function(a){return c("mouseout",a,this),this},d.Element.prototype.touchStarted=function(a){return c("touchstart",a,this),c("mousedown",a,this),this},d.Element.prototype.touchMoved=function(a){return c("touchmove",a,this),c("mousemove",a,this),this},d.Element.prototype.touchEnded=function(a){return c("touchend",a,this),c("mouseup",a,this),this},d.Element.prototype.dragOver=function(a){return c("dragover",a,this),this},d.Element.prototype.dragLeave=function(a){return c("dragleave",a,this),this},d.Element.prototype.drop=function(a,b){function e(b){var c=new d.File(b);return function(b){c.data=b.target.result,a(c)}}return window.File&&window.FileReader&&window.FileList&&window.Blob?(c("dragover",function(a){a.stopPropagation(),a.preventDefault()},this),c("dragleave",function(a){a.stopPropagation(),a.preventDefault()},this),arguments.length>1&&c("drop",b,this),c("drop",function(a){a.stopPropagation(),a.preventDefault();for(var b=a.dataTransfer.files,c=0;c2?a=this._getPath(a,b,c,d):"object"==typeof b&&(d=b),d&&"number"==typeof d.decimals&&(e=d.decimals),a.toPathData(e)},e.Font.prototype._getSVG=function(a,b,c,d){var e=3;return"string"==typeof a&&arguments.length>2?a=this._getPath(a,b,c,d):"object"==typeof b&&(d=b),d&&("number"==typeof d.decimals&&(e=d.decimals),"number"==typeof d.strokeWidth&&(a.strokeWidth=d.strokeWidth),void 0!==typeof d.fill&&(a.fill=d.fill),void 0!==typeof d.stroke&&(a.stroke=d.stroke)),a.toSVG(e)},e.Font.prototype._renderPath=function(a,b,c,d){var e,g=this.parent,h=g._graphics,i=h.drawingContext;e="object"==typeof a&&a.commands?a.commands:this._getPath(a,b,c,g._textSize,d).commands,i.beginPath();for(var j=0;jb?1:248>b?b:248,e!==b){e=b,f=1+e<<1,g=new Int32Array(f),h=new Array(f);for(var c=0;f>c;c++)h[c]=new Int32Array(256);for(var d,i,j,k,l=1,m=b-1;b>l;l++){g[b+l]=g[m]=i=m*m,j=h[b+l],k=h[m--];for(var n=0;256>n;n++)j[n]=k[n]=i*n}d=g[b]=b*b,j=h[b];for(var o=0;256>o;o++)j[o]=d*o}}function c(a,c){for(var i=d._toPixels(a),j=a.width,k=a.height,l=j*k,m=new Int32Array(l),n=0;l>n;n++)m[n]=d._getARGB(i,n);var o,p,q,r,s,t,u,v,w,x,y=new Int32Array(l),z=new Int32Array(l),A=new Int32Array(l),B=new Int32Array(l),C=0;b(c);var D,E,F,G;for(E=0;k>E;E++){for(D=0;j>D;D++){if(r=q=p=s=o=0,t=D-e,0>t)x=-t,t=0;else{if(t>=j)break;x=0}for(F=x;f>F&&!(t>=j);F++){var H=m[t+C];G=h[F],s+=G[(-16777216&H)>>>24],p+=G[(16711680&H)>>16],q+=G[(65280&H)>>8],r+=G[255&H],o+=g[F],t++}u=C+D,y[u]=s/o,z[u]=p/o,A[u]=q/o,B[u]=r/o}C+=j}for(C=0,v=-e,w=v*j,E=0;k>E;E++){for(D=0;j>D;D++){if(r=q=p=s=o=0,0>v)x=u=-v,t=D;else{if(v>=k)break;x=0,u=v,t=D+w}for(F=x;f>F&&!(u>=k);F++)G=h[F],s+=G[y[t]],p+=G[z[t]],q+=G[A[t]],r+=G[B[t]],o+=g[F],u++,t+=j;m[D+C]=s/o<<24|p/o<<16|q/o<<8|r/o}C+=j,w+=j,v++}d._setPixels(i,m)}var d={};d._toPixels=function(a){return a instanceof ImageData?a.data:a.getContext("2d").getImageData(0,0,a.width,a.height).data},d._getARGB=function(a,b){var c=4*b;return a[c+3]<<24&4278190080|a[c]<<16&16711680|a[c+1]<<8&65280|255&a[c+2]},d._setPixels=function(a,b){for(var c=0,d=0,e=a.length;e>d;d++)c=4*d,a[c+0]=(16711680&b[d])>>>16,a[c+1]=(65280&b[d])>>>8,a[c+2]=255&b[d],a[c+3]=(4278190080&b[d])>>>24},d._toImageData=function(a){return a instanceof ImageData?a:a.getContext("2d").getImageData(0,0,a.width,a.height)},d._createImageData=function(a,b){return d._tmpCanvas=document.createElement("canvas"),d._tmpCtx=d._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(a,b)},d.apply=function(a,b,c){var d=a.getContext("2d"),e=d.getImageData(0,0,a.width,a.height),f=b(e,c);f instanceof ImageData?d.putImageData(f,0,0,0,0,a.width,a.height):d.putImageData(e,0,0,0,0,a.width,a.height)},d.threshold=function(a,b){var c=d._toPixels(a);void 0===b&&(b=.5);for(var e=Math.floor(255*b),f=0;f=e?255:0,c[f]=c[f+1]=c[f+2]=g}},d.gray=function(a){for(var b=d._toPixels(a),c=0;cb||b>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var e=b-1,f=0;f>8)/e,c[f+1]=255*(h*b>>8)/e,c[f+2]=255*(i*b>>8)/e}},d.dilate=function(a){for(var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d._toPixels(a),u=0,v=t.length?t.length/4:0,w=new Int32Array(v);v>u;)for(b=u,c=u+a.width;c>u;)e=f=d._getARGB(t,u),i=u-1,h=u+1,j=u-a.width,k=u+a.width,b>i&&(i=u),h>=c&&(h=u),0>j&&(j=0),k>=v&&(k=u),n=d._getARGB(t,j),m=d._getARGB(t,i),o=d._getARGB(t,k),l=d._getARGB(t,h),g=77*(e>>16&255)+151*(e>>8&255)+28*(255&e),q=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),p=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),r=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),s=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),q>g&&(f=m,g=q),p>g&&(f=l,g=p),r>g&&(f=n,g=r),s>g&&(f=o,g=s),w[u++]=f;d._setPixels(t,w)},d.erode=function(a){for(var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d._toPixels(a),u=0,v=t.length?t.length/4:0,w=new Int32Array(v);v>u;)for(b=u,c=u+a.width;c>u;)e=f=d._getARGB(t,u),i=u-1,h=u+1,j=u-a.width,k=u+a.width,b>i&&(i=u),h>=c&&(h=u),0>j&&(j=0),k>=v&&(k=u),n=d._getARGB(t,j),m=d._getARGB(t,i),o=d._getARGB(t,k),l=d._getARGB(t,h),g=77*(e>>16&255)+151*(e>>8&255)+28*(255&e),q=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),p=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),r=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),s=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),g>q&&(f=m,g=q),g>p&&(f=l,g=p),g>r&&(f=n,g=r),g>s&&(f=o,g=s),w[u++]=f;d._setPixels(t,w)};var e,f,g,h;return d.blur=function(a,b){c(a,b)},d}({}),amdclean.core_p5Renderer=function(a,b){var c=b;return c.Renderer=function(a,b,d){c.Element.call(this,a,b),this.canvas=a,this._pInst=b,d?(this._isMainCanvas=!0,this._pInst._setProperty("_curElement",this),this._pInst._setProperty("canvas",this.canvas),this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height)):(this.canvas.style.display="none",this._styles=[])},c.Renderer.prototype=Object.create(c.Element.prototype),c.Renderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.elt.width=a*this._pInst.pixelDensity,this.elt.height=b*this._pInst.pixelDensity,this.elt.style.width=a+"px",this.elt.style.height=b+"px",this._isMainCanvas&&(this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height))},c.Renderer}({},amdclean.core_core),amdclean.core_p5Renderer2D=function(a,b,c,d,e,f){var g=b,h=c,i=d,j=e,k="rgba(0,0,0,0)";return g.Renderer2D=function(a,b,c){return g.Renderer.call(this,a,b,c),this.drawingContext=this.canvas.getContext("2d"),this._pInst._setProperty("drawingContext",this.drawingContext),this},g.Renderer2D.prototype=Object.create(g.Renderer.prototype),g.Renderer2D.prototype._applyDefaults=function(){this.drawingContext.fillStyle=i._DEFAULT_FILL,this.drawingContext.strokeStyle=i._DEFAULT_STROKE,this.drawingContext.lineCap=i.ROUND,this.drawingContext.font="normal 12px sans-serif"},g.Renderer2D.prototype.resize=function(a,b){g.Renderer.prototype.resize.call(this,a,b),this.drawingContext.scale(this._pInst.pixelDensity,this._pInst.pixelDensity)},g.Renderer2D.prototype.background=function(){if(this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pInst.pixelDensity,this._pInst.pixelDensity),arguments[0]instanceof g.Image)this._pInst.image(arguments[0],0,0,this.width,this.height);else{var a=this.drawingContext.fillStyle,b=this._pInst.color.apply(this._pInst,arguments),c=b.toString();this.drawingContext.fillStyle=c,this.drawingContext.fillRect(0,0,this.width,this.height),this.drawingContext.fillStyle=a}this.drawingContext.restore()},g.Renderer2D.prototype.clear=function(){this.drawingContext.clearRect(0,0,this.width,this.height)},g.Renderer2D.prototype.fill=function(){var a=this.drawingContext,b=this._pInst.color.apply(this._pInst,arguments);a.fillStyle=b.toString()},g.Renderer2D.prototype.stroke=function(){var a=this.drawingContext,b=this._pInst.color.apply(this._pInst,arguments);a.strokeStyle=b.toString()},g.Renderer2D.prototype.image=function(a,b,c,d,e){var f=a.canvas||a.elt;try{this._pInst._tint&&a.canvas?this.drawingContext.drawImage(this._getTintedImageCanvas(a),b,c,d,e):this.drawingContext.drawImage(f,b,c,d,e)}catch(g){if("NS_ERROR_NOT_AVAILABLE"!==g.name)throw g}},g.Renderer2D.prototype._getTintedImageCanvas=function(a){if(!a.canvas)return a;var b=j._toPixels(a.canvas),c=document.createElement("canvas");c.width=a.canvas.width,c.height=a.canvas.height;for(var d=c.getContext("2d"),e=d.createImageData(a.canvas.width,a.canvas.height),f=e.data,g=0;gthis.width||b>this.height||0>a||0>b)return[0,0,0,255];var e=this.pixelDensity||this._pInst.pixelDensity;if(1===c&&1===d){for(var f=this.drawingContext.getImageData(a*e,b*e,c,d),h=f.data,i=[],j=0;j1?(c.beginPath(),c.arc(a,b,c.lineWidth/2,0,i.TWO_PI,!1),c.fill()):c.fillRect(a,b,1,1),void(c.fillStyle=e)):this},g.Renderer2D.prototype.quad=function(a,b,c,d,e,f,g,h){var i=this.drawingContext,j=this._pInst._doFill,l=this._pInst._doStroke;if(j&&!l){if(i.fillStyle===k)return this}else if(!j&&l&&i.strokeStyle===k)return this;return i.beginPath(),i.moveTo(a,b),i.lineTo(c,d),i.lineTo(e,f),i.lineTo(g,h),i.closePath(),j&&i.fill(),l&&i.stroke(),this},g.Renderer2D.prototype.rect=function(a,b,c,d,e,f,g,i){var j=this.drawingContext,l=this._pInst._doFill,m=this._pInst._doStroke;if(l&&!m){if(j.fillStyle===k)return this}else if(!l&&m&&j.strokeStyle===k)return this;var n=h.modeAdjust(a,b,c,d,this._pInst._rectMode);if(this._pInst._doStroke&&j.lineWidth%2===1&&j.translate(.5,.5),j.beginPath(),"undefined"==typeof e)j.rect(n.x,n.y,n.w,n.h);else{"undefined"==typeof f&&(f=e),"undefined"==typeof g&&(g=f),"undefined"==typeof i&&(i=g);var o=n.x,p=n.y,q=n.w,r=n.h,s=q/2,t=r/2;2*e>q&&(e=s),2*e>r&&(e=t),2*f>q&&(f=s),2*f>r&&(f=t),2*g>q&&(g=s),2*g>r&&(g=t),2*i>q&&(i=s),2*i>r&&(i=t),j.beginPath(),j.moveTo(o+e,p),j.arcTo(o+q,p,o+q,p+r,f),j.arcTo(o+q,p+r,o,p+r,g),j.arcTo(o,p+r,o,p,i),j.arcTo(o,p,o+q,p,e),j.closePath()}return this._pInst._doFill&&j.fill(),this._pInst._doStroke&&j.stroke(),this._pInst._doStroke&&j.lineWidth%2===1&&j.translate(-.5,-.5),this},g.Renderer2D.prototype.triangle=function(a,b,c,d,e,f){var g=this.drawingContext,h=this._pInst._doFill,i=this._pInst._doStroke;if(h&&!i){if(g.fillStyle===k)return this}else if(!h&&i&&g.strokeStyle===k)return this;g.beginPath(),g.moveTo(a,b),g.lineTo(c,d),g.lineTo(e,f),g.closePath(),h&&g.fill(),i&&g.stroke()},g.Renderer2D.prototype.endShape=function(a,b,c,d,e,f,g){if(0===b.length)return this;if(!this._pInst._doStroke&&!this._pInst._doFill)return this;var h,j=a===i.CLOSE;j&&!f&&b.push(b[0]);var k,l,m=b.length;if(!c||g!==i.POLYGON&&null!==g)if(!d||g!==i.POLYGON&&null!==g)if(!e||g!==i.POLYGON&&null!==g)if(g===i.POINTS)for(k=0;m>k;k++)h=b[k],this._pInst._doStroke&&this._pInst.stroke(h[6]),this._pInst.point(h[0],h[1]);else if(g===i.LINES)for(k=0;m>k+1;k+=2)h=b[k],this._pInst._doStroke&&this._pInst.stroke(b[k+1][6]),this._pInst.line(h[0],h[1],b[k+1][0],b[k+1][1]);else if(g===i.TRIANGLES)for(k=0;m>k+2;k+=3)h=b[k],this.drawingContext.beginPath(),this.drawingContext.moveTo(h[0],h[1]),this.drawingContext.lineTo(b[k+1][0],b[k+1][1]),this.drawingContext.lineTo(b[k+2][0],b[k+2][1]),this.drawingContext.lineTo(h[0],h[1]),this._pInst._doFill&&(this._pInst.fill(b[k+2][5]),this.drawingContext.fill()),this._pInst._doStroke&&(this._pInst.stroke(b[k+2][6]),this.drawingContext.stroke()),this.drawingContext.closePath();else if(g===i.TRIANGLE_STRIP)for(k=0;m>k+1;k++)h=b[k],this.drawingContext.beginPath(),this.drawingContext.moveTo(b[k+1][0],b[k+1][1]),this.drawingContext.lineTo(h[0],h[1]),this._pInst._doStroke&&this._pInst.stroke(b[k+1][6]),this._pInst._doFill&&this._pInst.fill(b[k+1][5]),m>k+2&&(this.drawingContext.lineTo(b[k+2][0],b[k+2][1]),this._pInst._doStroke&&this._pInst.stroke(b[k+2][6]),this._pInst._doFill&&this._pInst.fill(b[k+2][5])),this._doFillStrokeClose();else if(g===i.TRIANGLE_FAN){if(m>2)for(this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0][0],b[0][1]),this.drawingContext.lineTo(b[1][0],b[1][1]),this.drawingContext.lineTo(b[2][0],b[2][1]),this._pInst._doFill&&this._pInst.fill(b[2][5]),this._pInst._doStroke&&this._pInst.stroke(b[2][6]),this._doFillStrokeClose(),k=3;m>k;k++)h=b[k],this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0][0],b[0][1]),this.drawingContext.lineTo(b[k-1][0],b[k-1][1]),this.drawingContext.lineTo(h[0],h[1]),this._pInst._doFill&&this._pInst.fill(h[5]),this._pInst._doStroke&&this._pInst.stroke(h[6]),this._doFillStrokeClose()}else if(g===i.QUADS)for(k=0;m>k+3;k+=4){for(h=b[k],this.drawingContext.beginPath(),this.drawingContext.moveTo(h[0],h[1]),l=1;4>l;l++)this.drawingContext.lineTo(b[k+l][0],b[k+l][1]);this.drawingContext.lineTo(h[0],h[1]),this._pInst._doFill&&this._pInst.fill(b[k+3][5]),this._pInst._doStroke&&this._pInst.stroke(b[k+3][6]),this._doFillStrokeClose()}else if(g===i.QUAD_STRIP){if(m>3)for(k=0;m>k+1;k+=2)h=b[k],this.drawingContext.beginPath(),m>k+3?(this.drawingContext.moveTo(b[k+2][0],b[k+2][1]),this.drawingContext.lineTo(h[0],h[1]),this.drawingContext.lineTo(b[k+1][0],b[k+1][1]),this.drawingContext.lineTo(b[k+3][0],b[k+3][1]),this._pInst._doFill&&this._pInst.fill(b[k+3][5]),this._pInst._doStroke&&this._pInst.stroke(b[k+3][6])):(this.drawingContext.moveTo(h[0],h[1]),this.drawingContext.lineTo(b[k+1][0],b[k+1][1])),this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0][0],b[0][1]),k=1;m>k;k++)h=b[k],h.isVert&&(h.moveTo?this.drawingContext.moveTo(h[0],h[1]):this.drawingContext.lineTo(h[0],h[1]));this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),k=0;m>k;k++)b[k].isVert?b[k].moveTo?this.drawingContext.moveTo([0],b[k][1]):this.drawingContext.lineTo(b[k][0],b[k][1]):this.drawingContext.quadraticCurveTo(b[k][0],b[k][1],b[k][2],b[k][3]);this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),k=0;m>k;k++)b[k].isVert?b[k].moveTo?this.drawingContext.moveTo(b[k][0],b[k][1]):this.drawingContext.lineTo(b[k][0],b[k][1]):this.drawingContext.bezierCurveTo(b[k][0],b[k][1],b[k][2],b[k][3],b[k][4],b[k][5]);this._doFillStrokeClose()}else if(m>3){var n=[],o=1-this._pInst._curveTightness;for(this.drawingContext.beginPath(),this.drawingContext.moveTo(b[1][0],b[1][1]),k=1;m>k+2;k++)h=b[k],n[0]=[h[0],h[1]],n[1]=[h[0]+(o*b[k+1][0]-o*b[k-1][0])/6,h[1]+(o*b[k+1][1]-o*b[k-1][1])/6],n[2]=[b[k+1][0]+(o*b[k][0]-o*b[k+2][0])/6,b[k+1][1]+(o*b[k][1]-o*b[k+2][1])/6],n[3]=[b[k+1][0],b[k+1][1]],this.drawingContext.bezierCurveTo(n[1][0],n[1][1],n[2][0],n[2][1],n[3][0],n[3][1]);j&&this.drawingContext.lineTo(b[k+1][0],b[k+1][1]),this._doFillStrokeClose()}return c=!1,d=!1,e=!1,f=!1,j&&b.pop(),this},g.Renderer2D.prototype.noSmooth=function(){return"imageSmoothingEnabled"in this.drawingContext?this.drawingContext.imageSmoothingEnabled=!1:"mozImageSmoothingEnabled"in this.drawingContext?this.drawingContext.mozImageSmoothingEnabled=!1:"webkitImageSmoothingEnabled"in this.drawingContext?this.drawingContext.webkitImageSmoothingEnabled=!1:"msImageSmoothingEnabled"in this.drawingContext&&(this.drawingContext.msImageSmoothingEnabled=!1),this},g.Renderer2D.prototype.smooth=function(){return"imageSmoothingEnabled"in this.drawingContext?this.drawingContext.imageSmoothingEnabled=!0:"mozImageSmoothingEnabled"in this.drawingContext?this.drawingContext.mozImageSmoothingEnabled=!0:"webkitImageSmoothingEnabled"in this.drawingContext?this.drawingContext.webkitImageSmoothingEnabled=!0:"msImageSmoothingEnabled"in this.drawingContext&&(this.drawingContext.msImageSmoothingEnabled=!0),this},g.Renderer2D.prototype.strokeCap=function(a){return(a===i.ROUND||a===i.SQUARE||a===i.PROJECT)&&(this.drawingContext.lineCap=a),this},g.Renderer2D.prototype.strokeJoin=function(a){return(a===i.ROUND||a===i.BEVEL||a===i.MITER)&&(this.drawingContext.lineJoin=a),this},g.Renderer2D.prototype.strokeWeight=function(a){return"undefined"==typeof a||0===a?this.drawingContext.lineWidth=1e-4:this.drawingContext.lineWidth=a,this},g.Renderer2D.prototype._getFill=function(){return this.drawingContext.fillStyle},g.Renderer2D.prototype._getStroke=function(){return this.drawingContext.strokeStyle},g.Renderer2D.prototype.bezier=function(a,b,c,d,e,f,g,h){return this._pInst.beginShape(),this._pInst.vertex(a,b),this._pInst.bezierVertex(c,d,e,f,g,h),this._pInst.endShape(),this},g.Renderer2D.prototype.curve=function(a,b,c,d,e,f,g,h){return this._pInst.beginShape(),this._pInst.curveVertex(a,b),this._pInst.curveVertex(c,d),this._pInst.curveVertex(e,f),this._pInst.curveVertex(g,h),this._pInst.endShape(),this},g.Renderer2D.prototype._doFillStrokeClose=function(){this._pInst._doFill&&this.drawingContext.fill(),this._pInst._doStroke&&this.drawingContext.stroke(),this.drawingContext.closePath()},g.Renderer2D.prototype.applyMatrix=function(a,b,c,d,e,f){this.drawingContext.transform(a,b,c,d,e,f)},g.Renderer2D.prototype.resetMatrix=function(){return this.drawingContext.setTransform(1,0,0,1,0,0),this},g.Renderer2D.prototype.rotate=function(a){this.drawingContext.rotate(a)},g.Renderer2D.prototype.scale=function(){var a=1,b=1;return 1===arguments.length?a=b=arguments[0]:(a=arguments[0],b=arguments[1]),this.drawingContext.scale(a,b),this},g.Renderer2D.prototype.shearX=function(a){return this._pInst._angleMode===i.DEGREES&&(a=this._pInst.radians(a)),this.drawingContext.transform(1,0,this._pInst.tan(a),1,0,0),this},g.Renderer2D.prototype.shearY=function(a){return this._pInst._angleMode===i.DEGREES&&(a=this._pInst.radians(a)),this.drawingContext.transform(1,this._pInst.tan(a),0,1,0,0),this},g.Renderer2D.prototype.translate=function(a,b){return this.drawingContext.translate(a,b),this},g.Renderer2D.prototype.text=function(a,b,c,d,e){var f,g,h,j,k,l,m,n,o,p,q=this._pInst;if(q._doFill||q._doStroke){if("string"!=typeof a&&(a=a.toString()),a=a.replace(/(\t)/g," "),f=a.split("\n"),"undefined"!=typeof d){for(o=0,h=0;hd?(k=n[g]+" ",o+=q.textLeading()):k=l;switch(this.drawingContext.textAlign){case i.CENTER:b+=d/2;break;case i.RIGHT:b+=d}if("undefined"!=typeof e)switch(this.drawingContext.textBaseline){case i.BOTTOM:c+=e-o;break;case i._CTX_MIDDLE:c+=(e-o)/2;break;case i.BASELINE:p=!0,this.drawingContext.textBaseline=i.TOP}for(h=0;hd?(this._renderText(q,k,b,c),k=n[g]+" ",c+=q.textLeading()):k=l;this._renderText(q,k,b,c),c+=q.textLeading()}}else for(j=0;j0&&this.loadPixels()},d.Image.prototype.copy=function(){d.prototype.copy.apply(this,arguments)},d.Image.prototype.mask=function(a){void 0===a&&(a=this);var b=this.drawingContext.globalCompositeOperation,c=1;a instanceof d.Renderer&&(c=a._pInst.pixelDensity);var e=[a,0,0,c*a.width,c*a.height,0,0,this.width,this.height];this.drawingContext.globalCompositeOperation="destination-in",this.copy.apply(this,e),this.drawingContext.globalCompositeOperation=b},d.Image.prototype.filter=function(a,b){e.apply(this.canvas,e[a.toLowerCase()],b)},d.Image.prototype.blend=function(){d.prototype.blend.apply(this,arguments)},d.Image.prototype.save=function(a,b){var c;if(b)switch(b.toLowerCase()){case"png":c="image/png";break;case"jpeg":c="image/jpeg";break;case"jpg":c="image/jpeg";break;default:c="image/png"}else b="png",c="image/png";var e="image/octet-stream",f=this.canvas.toDataURL(c);f=f.replace(c,e),d.prototype.downloadFile(f,a,b)},d.Image}({},amdclean.core_core,amdclean.image_filters),amdclean.math_polargeometry=function(a){return{degreesToRadians:function(a){return 2*Math.PI*a/360},radiansToDegrees:function(a){return 360*a/(2*Math.PI)}}}({}),amdclean.math_p5Vector=function(a,b,c,d){"use strict";var e=b,f=c,g=d;return e.Vector=function(){var a,b,c;arguments[0]instanceof e?(this.p5=arguments[0],a=arguments[1][0]||0,b=arguments[1][1]||0,c=arguments[1][2]||0):(a=arguments[0]||0,b=arguments[1]||0,c=arguments[2]||0),this.x=a,this.y=b,this.z=c},e.Vector.prototype.toString=function(){return"p5.Vector Object : ["+this.x+", "+this.y+", "+this.z+"]"},e.Vector.prototype.set=function(a,b,c){return a instanceof e.Vector?(this.x=a.x||0,this.y=a.y||0,this.z=a.z||0,this):a instanceof Array?(this.x=a[0]||0,this.y=a[1]||0,this.z=a[2]||0,this):(this.x=a||0,this.y=b||0,this.z=c||0,this)},e.Vector.prototype.copy=function(){return this.p5?new e.Vector(this.p5,[this.x,this.y,this.z]):new e.Vector(this.x,this.y,this.z)},e.Vector.prototype.add=function(a,b,c){return a instanceof e.Vector?(this.x+=a.x||0,this.y+=a.y||0,this.z+=a.z||0,this):a instanceof Array?(this.x+=a[0]||0,this.y+=a[1]||0,this.z+=a[2]||0,this):(this.x+=a||0,this.y+=b||0,this.z+=c||0,this)},e.Vector.prototype.sub=function(a,b,c){return a instanceof e.Vector?(this.x-=a.x||0,this.y-=a.y||0,this.z-=a.z||0,this):a instanceof Array?(this.x-=a[0]||0,this.y-=a[1]||0,this.z-=a[2]||0,this):(this.x-=a||0,this.y-=b||0,this.z-=c||0,this)},e.Vector.prototype.mult=function(a){return this.x*=a||0,this.y*=a||0,this.z*=a||0,this},e.Vector.prototype.div=function(a){return this.x/=a,this.y/=a,this.z/=a,this},e.Vector.prototype.mag=function(){return Math.sqrt(this.magSq())},e.Vector.prototype.magSq=function(){var a=this.x,b=this.y,c=this.z;return a*a+b*b+c*c},e.Vector.prototype.dot=function(a,b,c){return a instanceof e.Vector?this.dot(a.x,a.y,a.z):this.x*(a||0)+this.y*(b||0)+this.z*(c||0)},e.Vector.prototype.cross=function(a){var b=this.y*a.z-this.z*a.y,c=this.z*a.x-this.x*a.z,d=this.x*a.y-this.y*a.x;return this.p5?new e.Vector(this.p5,[b,c,d]):new e.Vector(b,c,d)},e.Vector.prototype.dist=function(a){var b=a.copy().sub(this);return b.mag()},e.Vector.prototype.normalize=function(){return this.div(this.mag())},e.Vector.prototype.limit=function(a){var b=this.magSq();return b>a*a&&(this.div(Math.sqrt(b)),this.mult(a)),this},e.Vector.prototype.setMag=function(a){return this.normalize().mult(a)},e.Vector.prototype.heading=function(){var a=Math.atan2(this.y,this.x);return this.p5?this.p5._angleMode===g.RADIANS?a:f.radiansToDegrees(a):a},e.Vector.prototype.rotate=function(a){this.p5&&this.p5._angleMode===g.DEGREES&&(a=f.degreesToRadians(a));var b=this.heading()+a,c=this.mag();return this.x=Math.cos(b)*c,this.y=Math.sin(b)*c,this},e.Vector.prototype.lerp=function(a,b,c,d){return a instanceof e.Vector?this.lerp(a.x,a.y,a.z,b):(this.x+=(a-this.x)*d||0,this.y+=(b-this.y)*d||0,this.z+=(c-this.z)*d||0,this)},e.Vector.prototype.array=function(){return[this.x||0,this.y||0,this.z||0]},e.Vector.prototype.equals=function(a,b,c){var d,f,g;return a instanceof e.Vector?(d=a.x||0,f=a.y||0,g=a.z||0):a instanceof Array?(d=a[0]||0,f=a[1]||0,g=a[2]||0):(d=a||0,f=b||0,g=c||0),this.x===d&&this.y===f&&this.z===g},e.Vector.fromAngle=function(a){return this.p5&&this.p5._angleMode===g.DEGREES&&(a=f.degreesToRadians(a)),this.p5?new e.Vector(this.p5,[Math.cos(a),Math.sin(a),0]):new e.Vector(Math.cos(a),Math.sin(a),0)},e.Vector.random2D=function(){var a;return a=this.p5?this.p5._angleMode===g.DEGREES?this.p5.random(360):this.p5.random(g.TWO_PI):Math.random()*Math.PI*2,this.fromAngle(a)},e.Vector.random3D=function(){var a,b;this.p5?(a=this.p5.random(0,g.TWO_PI),b=this.p5.random(-1,1)):(a=Math.random()*Math.PI*2,b=2*Math.random()-1);var c=Math.sqrt(1-b*b)*Math.cos(a),d=Math.sqrt(1-b*b)*Math.sin(a);return this.p5?new e.Vector(this.p5,[c,d,b]):new e.Vector(c,d,b)},e.Vector.add=function(a,b,c){return c?c.set(a):c=a.copy(),c.add(b),c},e.Vector.sub=function(a,b,c){return c?c.set(a):c=a.copy(),c.sub(b),c},e.Vector.mult=function(a,b,c){return c?c.set(a):c=a.copy(),c.mult(b),c},e.Vector.div=function(a,b,c){return c?c.set(a):c=a.copy(),c.div(b),c},e.Vector.dot=function(a,b){return a.dot(b)},e.Vector.cross=function(a,b){return a.cross(b)},e.Vector.dist=function(a,b){return a.dist(b)},e.Vector.lerp=function(a,b,c,d){return d?d.set(a):d=a.copy(),d.lerp(b,c),d},e.Vector.angleBetween=function(a,b){var c=Math.acos(a.dot(b)/(a.mag()*b.mag()));return this.p5&&this.p5._angleMode===g.DEGREES&&(c=f.radiansToDegrees(c)),c},e.Vector}({},amdclean.core_core,amdclean.math_polargeometry,amdclean.core_constants),amdclean.io_p5TableRow=function(a,b){"use strict";var c=b;return c.TableRow=function(a,b){var c=[],d={};a&&(b=b||",",c=a.split(b));for(var e=0;e=0))throw'This table has no column named "'+a+'"';this.obj[a]=b,this.arr[c]=b}else{if(!(a=0))throw'This table has no column named "'+a+'"';d=b[a],e[d]=b}else e[f]=this.rows[f].obj;return e},c.Table.prototype.getArray=function(){for(var a=[],b=0;bh;h++)g.push(Math.sqrt(d.prototype.lerp(a.rgba[h]*a.rgba[h],b.rgba[h]*b.rgba[h],c)));return new d.Color(this,g)}return Math.sqrt(d.prototype.lerp(a*a,b*b,c))},d.prototype.lightness=function(a){if(a instanceof d.Color||a instanceof Array)return this.color(a).getLightness();throw new Error("Needs p5.Color or pixel array as argument.")},d.prototype.red=function(a){if(a instanceof d.Color||a instanceof Array)return this.color(a).getRed();throw new Error("Needs p5.Color or pixel array as argument.")},d.prototype.saturation=function(a){if(!a instanceof d.Color)throw new Error("Needs p5.Color as argument.");return a.getSaturation()},d}({},amdclean.core_core,amdclean.color_p5Color),amdclean.color_setting=function(a,b,c,d){"use strict";var e=b,f=c;return e.prototype._doStroke=!0,e.prototype._doFill=!0,e.prototype._strokeSet=!1,e.prototype._fillSet=!1,e.prototype._colorMode=f.RGB,e.prototype._colorMaxes={rgb:[255,255,255,255],hsb:[360,100,100,1],hsl:[360,100,100,1]},e.prototype.background=function(){return arguments[0]instanceof e.Image?this.image(arguments[0],0,0,this.width,this.height):this._graphics.background.apply(this._graphics,arguments),this},e.prototype.clear=function(){return this._graphics.clear(),this},e.prototype.colorMode=function(){if(arguments[0]===f.RGB||arguments[0]===f.HSB||arguments[0]===f.HSL){this._colorMode=arguments[0];var a=this._colorMaxes[this._colorMode];2===arguments.length?(a[0]=arguments[1],a[1]=arguments[1],a[2]=arguments[1],a[3]=arguments[1]):arguments.length>2&&(a[0]=arguments[1],a[1]=arguments[2],a[2]=arguments[3]),5===arguments.length&&(a[3]=arguments[4])}return this},e.prototype.fill=function(){return this._setProperty("_fillSet",!0),this._setProperty("_doFill",!0),this._graphics.fill.apply(this._graphics,arguments),this},e.prototype.noFill=function(){return this._setProperty("_doFill",!1),this},e.prototype.noStroke=function(){return this._setProperty("_doStroke",!1),this},e.prototype.stroke=function(){return this._setProperty("_strokeSet",!0),this._setProperty("_doStroke",!0),this._graphics.stroke.apply(this._graphics,arguments),this},e}({},amdclean.core_core,amdclean.core_constants,amdclean.color_p5Color),amdclean.utilities_conversion=function(a,b){"use strict";var c=b;return c.prototype["float"]=function(a){return parseFloat(a)},c.prototype["int"]=function(a,b){return"string"==typeof a?(b=b||10,parseInt(a,b)):"number"==typeof a?0|a:"boolean"==typeof a?a?1:0:a instanceof Array?a.map(function(a){return c.prototype["int"](a,b)}):void 0},c.prototype.str=function(a){return a instanceof Array?a.map(c.prototype.str):String(a)},c.prototype["boolean"]=function(a){return"number"==typeof a?0!==a:"string"==typeof a?"true"===a.toLowerCase():"boolean"==typeof a?a:a instanceof Array?a.map(c.prototype["boolean"]):void 0},c.prototype["byte"]=function(a){var b=c.prototype["int"](a,10);return"number"==typeof b?(b+128)%256-128:b instanceof Array?b.map(c.prototype["byte"]):void 0; +},c.prototype["char"]=function(a){return"number"!=typeof a||isNaN(a)?a instanceof Array?a.map(c.prototype["char"]):"string"==typeof a?c.prototype["char"](parseInt(a,10)):void 0:String.fromCharCode(a)},c.prototype.unchar=function(a){return"string"==typeof a&&1===a.length?a.charCodeAt(0):a instanceof Array?a.map(c.prototype.unchar):void 0},c.prototype.hex=function(a,b){if(b=void 0===b||null===b?b=8:b,a instanceof Array)return a.map(function(a){return c.prototype.hex(a,b)});if("number"==typeof a){0>a&&(a=4294967295+a+1);for(var d=Number(a).toString(16).toUpperCase();d.length=b&&(d=d.substring(d.length-b,d.length)),d}},c.prototype.unhex=function(a){return a instanceof Array?a.map(c.prototype.unhex):parseInt("0x"+a,16)},c}({},amdclean.core_core),amdclean.utilities_array_functions=function(a,b){"use strict";var c=b;return c.prototype.append=function(a,b){return a.push(b),a},c.prototype.arrayCopy=function(a,b,c,d,e){var f,g;"undefined"!=typeof e?(g=Math.min(e,a.length),f=d,a=a.slice(b,g+b)):("undefined"!=typeof c?(g=c,g=Math.min(g,a.length)):g=a.length,f=0,c=b,a=a.slice(0,g)),Array.prototype.splice.apply(c,[f,g].concat(a))},c.prototype.concat=function(a,b){return a.concat(b)},c.prototype.reverse=function(a){return a.reverse()},c.prototype.shorten=function(a){return a.pop(),a},c.prototype.shuffle=function(a,b){a=b||ArrayBuffer.isView(a)?a:a.slice();for(var c,d,e=a.length;e>1;)c=Math.random()*e|0,d=a[--e],a[e]=a[c],a[c]=d;return a},c.prototype.sort=function(a,b){var c=b?a.slice(0,Math.min(b,a.length)):a,d=b?a.slice(Math.min(b,a.length)):[];return c="string"==typeof c[0]?c.sort():c.sort(function(a,b){return a-b}),c.concat(d)},c.prototype.splice=function(a,b,c){return Array.prototype.splice.apply(a,[c,0].concat(b)),a},c.prototype.subset=function(a,b,c){return"undefined"!=typeof c?a.slice(b,b+c):a.slice(b,a.length)},c}({},amdclean.core_core),amdclean.utilities_string_functions=function(a,b){"use strict";function c(){var a=arguments[0],b=0>a,c=b?a.toString().substring(1):a.toString(),d=c.indexOf("."),e=-1!==d?c.substring(0,d):c,f=-1!==d?c.substring(d+1):"",g=b?"-":"";if(3===arguments.length){var h="";(-1!==d||arguments[2]-f.length>0)&&(h="."),f.length>arguments[2]&&(f=f.substring(0,arguments[2]));for(var i=0;ic.length){c+=-1===b?".":"";for(var e=arguments[1]-c.length+1,f=0;e>f;f++)c+="0"}else c=c.substring(0,arguments[1]+1);return d+c}function e(){return parseFloat(arguments[0])>0?"+"+arguments[0].toString():arguments[0].toString()}function f(){return parseFloat(arguments[0])>0?" "+arguments[0].toString():arguments[0].toString()}var g=b;return g.prototype.join=function(a,b){return a.join(b)},g.prototype.match=function(a,b){return a.match(b)},g.prototype.matchAll=function(a,b){for(var c=new RegExp(b,"g"),d=c.exec(a),e=[];null!==d;)e.push(d),d=c.exec(a);return e},g.prototype.nf=function(){if(arguments[0]instanceof Array){var a=arguments[1],b=arguments[2];return arguments[0].map(function(d){return c(d,a,b)})}var d=Object.prototype.toString.call(arguments[0]);return"[object Arguments]"===d?3===arguments[0].length?this.nf(arguments[0][0],arguments[0][1],arguments[0][2]):2===arguments[0].length?this.nf(arguments[0][0],arguments[0][1]):this.nf(arguments[0][0]):c.apply(this,arguments)},g.prototype.nfc=function(){if(arguments[0]instanceof Array){var a=arguments[1];return arguments[0].map(function(b){return d(b,a)})}return d.apply(this,arguments)},g.prototype.nfp=function(){var a=this.nf.apply(this,arguments);return a instanceof Array?a.map(e):e(a)},g.prototype.nfs=function(){var a=this.nf.apply(this,arguments);return a instanceof Array?a.map(f):f(a)},g.prototype.split=function(a,b){return a.split(b)},g.prototype.splitTokens=function(){var a=arguments.length>0?arguments[1]:/\s/g;return arguments[0].split(a).filter(function(a){return a})},g.prototype.trim=function(a){return a instanceof Array?a.map(this.trim):a.trim()},g}({},amdclean.core_core),amdclean.core_environment=function(a,b,c){"use strict";function d(a){var b=document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled;if(!b)throw new Error("Fullscreen not enabled in this browser.");a.requestFullscreen?a.requestFullscreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen?a.webkitRequestFullscreen():a.msRequestFullscreen&&a.msRequestFullscreen()}function e(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()}var f=b,g=c,h=[g.ARROW,g.CROSS,g.HAND,g.MOVE,g.TEXT,g.WAIT];return f.prototype._frameRate=0,f.prototype._lastFrameTime=window.performance.now(),f.prototype._targetFrameRate=60,window.console&&console.log?f.prototype.print=function(a){try{var b=JSON.parse(JSON.stringify(a));console.log(b)}catch(c){console.log(a)}}:f.prototype.print=function(){},f.prototype.println=f.prototype.print,f.prototype.frameCount=0,f.prototype.focused=document.hasFocus(),f.prototype.cursor=function(a,b,c){var d="auto",e=this._curElement.elt;if(h.indexOf(a)>-1)d=a;else if("string"==typeof a){var f="";b&&c&&"number"==typeof b&&"number"==typeof c&&(f=b+" "+c),d="http://"!==a.substring(0,6)?"url("+a+") "+f+", auto":/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(a)?"url("+a+") "+f+", auto":a}e.style.cursor=d},f.prototype.frameRate=function(a){return"undefined"==typeof a?this._frameRate:(this._setProperty("_targetFrameRate",a),this._runFrames(),this)},f.prototype.getFrameRate=function(){return this.frameRate()},f.prototype.setFrameRate=function(a){return this.frameRate(a)},f.prototype.noCursor=function(){this._curElement.elt.style.cursor="none"},f.prototype.displayWidth=screen.width,f.prototype.displayHeight=screen.height,f.prototype.windowWidth=window.innerWidth,f.prototype.windowHeight=window.innerHeight,f.prototype._onresize=function(a){this._setProperty("windowWidth",window.innerWidth),this._setProperty("windowHeight",window.innerHeight);var b,c=this._isGlobal?window:this;"function"==typeof c.windowResized&&(b=c.windowResized(a),void 0===b||b||a.preventDefault())},f.prototype.width=0,f.prototype.height=0,f.prototype.fullscreen=function(a){return"undefined"==typeof a?document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement:void(a?d(document.documentElement):e())},f.prototype.devicePixelScaling=function(a){a?"number"==typeof a?this.pixelDensity=a:this.pixelDensity=window.devicePixelRatio||1:this.pixelDensity=1,this.resizeCanvas(this.width,this.height,!0)},f.prototype.getURL=function(){return location.href},f.prototype.getURLPath=function(){return location.pathname.split("/").filter(function(a){return""!==a})},f.prototype.getURLParams=function(){for(var a,b=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim,c={};null!=(a=b.exec(location.search));)a.index===b.lastIndex&&b.lastIndex++,c[a[1]]=a[2];return c},f}({},amdclean.core_core,amdclean.core_constants),amdclean.image_image=function(a,b,c){"use strict";var d=b,e=c;d.prototype._imageMode=e.CORNER,d.prototype._tint=null,d.prototype.createImage=function(a,b){return new d.Image(a,b)};var f=[];return d.prototype.saveCanvas=function(a,b,c){b||(b=d.prototype._checkFileExtension(a,b)[1],""===b&&(b="png"));var e;if(c?e=c:this._curElement&&this._curElement.elt&&(e=this._curElement.elt),d.prototype._isSafari()){var f="Hello, Safari user!\n";f+="Now capturing a screenshot...\n",f+="To save this image,\n",f+="go to File --> Save As.\n",alert(f),window.location.href=e.toDataURL()}else{var g;if("undefined"==typeof b)b="png",g="image/png";else switch(b){case"png":g="image/png";break;case"jpeg":g="image/jpeg";break;case"jpg":g="image/jpeg";break;default:g="image/png"}var h="image/octet-stream",i=e.toDataURL(g);i=i.replace(g,h),d.prototype.downloadFile(i,a,b)}},d.prototype.saveFrames=function(a,b,c,e,g){var h=c||3;h=d.prototype.constrain(h,0,15),h=1e3*h;var i=e||15;i=d.prototype.constrain(i,0,22);var j=0,k=d.prototype._makeFrame,l=this._curElement.elt,m=setInterval(function(){k(a+j,b,l),j++},1e3/i);setTimeout(function(){if(clearInterval(m),g)g(f);else for(var a=0;a-1&&n(c)}function d(a,b,c){g&&(e(),g=!1),"undefined"===l(c)?c="#B40033":"number"===l(c)&&(c=t[c]),"load"===b.substring(0,4)?console.log("%c> p5.js says: "+a+"%c[https://github.com/processing/p5.js/wiki/Local-server]","background-color:"+c+";color:#FFF;","background-color:transparent;color:"+c+";","background-color:"+c+";color:#FFF;","background-color:transparent;color:"+c+";"):console.log("%c> p5.js says: "+a+"%c [http://p5js.org/reference/#p5/"+b+"]","background-color:"+c+";color:#FFF;","background-color:transparent;color:"+c+";")}function e(){var a="transparent",b="#ED225D",c="#ED225D",d="white";console.log("%c _ \n /\\| |/\\ \n \\ ` ' / \n / , . \\ \n \\/|_|\\/ \n\n%c> p5.js says: Welcome! This is your friendly debugger. To turn me off switch to using “p5.min.js”.","background-color:"+a+";color:"+b+";","background-color:"+c+";color:"+d+";")}for(var f=b,g=!0,h={},i=h.toString,j=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error"],k=0;k=0},o=["Number","Integer","Number/Constant"],p=0,q=1,r=2,s=3,t=["#2D7BB6","#EE9900","#4DB200","#C83C00"];f.prototype._validateParameters=function(a,b,e){m(e[0])||(e=[e]);for(var f,g=Math.abs(b.length-e[0].length),h=0,i=1,j=e.length;j>i;i++){var k=Math.abs(b.length-e[i].length);g>=k&&(h=i,g=k)}var n="X";g>0&&(f="You wrote "+a+"(",b.length>0&&(f+=n+(","+n).repeat(b.length-1)),f+="). "+a+" was expecting "+e[h].length+" parameters. Try "+a+"(",e[h].length>0&&(f+=n+(","+n).repeat(e[h].length-1)),f+=").",e.length>1&&(f+=" "+a+" takes different numbers of parameters depending on what you want to do. Click this link to learn more: "),d(f,a,p));for(var o=0;o1&&(f+=" "+a+" takes different numbers of parameters depending on what you want to do. Click this link to learn more:"),d(f,a,r))}};var u={0:{fileType:"image",method:"loadImage",message:" hosting the image online,"},1:{fileType:"XML file",method:"loadXML"},2:{fileType:"table file",method:"loadTable"},3:{fileType:"text file",method:"loadStrings"}};return f._friendlyFileLoadError=function(a,b){var c=u[a],e="It looks like there was a problem loading your "+c.fileType+". Try checking if the file path%c ["+b+"] %cis correct,"+(c.message||"")+" or running a local server.";d(e,c.method,s)},f}({},amdclean.core_core),amdclean.image_loading_displaying=function(a,b,c,d,e,f){"use strict";var g=b,h=c,i=d,j=e;return g.prototype.loadImage=function(a,b,c){var d=new Image,e=new g.Image(1,1,this);return d.onload=function(){e.width=e.canvas.width=d.width,e.height=e.canvas.height=d.height,e.canvas.getContext("2d").drawImage(d,0,0),"function"==typeof b&&b(e)},d.onerror=function(a){g._friendlyFileLoadError(0,d.src),"function"==typeof c&&c(a)},0!==a.indexOf("data:image/")&&(d.crossOrigin="Anonymous"),d.src=a,e},g.prototype.image=function(a,b,c,d,e){b=b||0,c=c||0,d=d||a.width,e=e||a.height;var f=i.modeAdjust(b,c,d,e,this._imageMode);this._graphics.image(a,f.x,f.y,f.w,f.h)},g.prototype.tint=function(){var a=this.color.apply(this,arguments);this._tint=a.rgba},g.prototype.noTint=function(){this._tint=null},g.prototype._getTintedImageCanvas=function(a){if(!a.canvas)return a;var b=h._toPixels(a.canvas),c=document.createElement("canvas");c.width=a.canvas.width,c.height=a.canvas.height;for(var d=c.getContext("2d"),e=d.createImageData(a.canvas.width,a.canvas.height),f=e.data,g=0;g0;)self._completeHandlers.shift()(a)}function success(resp){var type=o.type||resp&&setType(resp.getResponseHeader("Content-Type"));resp="jsonp"!==type?self.request:resp;var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=filteredResponse;try{resp.responseText=r}catch(e){}if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}for(self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp),self._successHandler(resp);self._fulfillmentHandlers.length>0;)resp=self._fulfillmentHandlers.shift()(resp);complete(resp)}function timedOut(){self._timedOut=!0,self.request.abort()}function error(a,b,c){for(a=self.request,self._responseArgs.resp=a,self._responseArgs.msg=b,self._responseArgs.t=c,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(a,b,c);complete(a)}this.url="string"==typeof o?o:o.url,this.timeout=null,this._fulfilled=!1,this._successHandler=function(){},this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){timedOut()},o.timeout)),o.success&&(this._successHandler=function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function normalize(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function serial(a,b){var c,d,e,f,g=a.name,h=a.tagName.toLowerCase(),i=function(a){a&&!a.disabled&&b(g,normalize(a.attributes.value&&a.attributes.value.specified?a.value:a.text))};if(!a.disabled&&g)switch(h){case"input":/reset|button|image|file/i.test(a.type)||(c=/checkbox/i.test(a.type),d=/radio/i.test(a.type),e=a.value,(!(c||d)||a.checked)&&b(g,normalize(c&&""===e?"on":e)));break;case"textarea":b(g,normalize(a.value));break;case"select":if("select-one"===a.type.toLowerCase())i(a.selectedIndex>=0?a.options[a.selectedIndex]:null);else for(f=0;a.length&&f-1&&(c=a.split(".").pop()),b&&c!==b&&(c=b,a=a+"."+c),[a,c]}function g(a){document.body.removeChild(a.target)}var h=b,c=c;h.prototype.loadFont=function(a,b){var c=new h.Font(this);return opentype.load(a,function(a,d){if(a)throw Error(a);c.font=d,"undefined"!=typeof b&&b(c)}),c},h.prototype.createInput=function(){throw"not yet implemented"},h.prototype.createReader=function(){throw"not yet implemented"},h.prototype.loadBytes=function(){throw"not yet implemented"},h.prototype.loadJSON=function(){var a=arguments[0],b=arguments[1],d=[],e="json";return"string"==typeof arguments[2]&&("jsonp"===arguments[2]||"json"===arguments[2])&&(e=arguments[2]),c({url:a,type:e,crossOrigin:!0}).then(function(a){for(var c in a)d[c]=a[c];"undefined"!=typeof b&&b(a)}),d},h.prototype.loadStrings=function(a,b){var c=[],d=new XMLHttpRequest;return d.open("GET",a,!0),d.onreadystatechange=function(){if(4===d.readyState&&200===d.status){var e=d.responseText.match(/[^\r\n]+/g);for(var f in e)c[f]=e[f];"undefined"!=typeof b&&b(c)}else h._friendlyFileLoadError(3,a)},d.send(null),c},h.prototype.loadTable=function(a){for(var b=null,d=[],f=!1,g=",",i=!1,j=1;j"),d.println("");var k=' "),d.println(""),d.println(" "),"0"!==e[0]){d.println(" ");for(var l=0;l"+m),d.println(" ")}d.println(" ")}for(var n=0;n");for(var o=0;o"+q),d.println(" ")}d.println(" ")}d.println("
"),d.println(""),d.print("")}d.close(),d.flush()};var i=function(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};return h.prototype.writeFile=function(a,b,c){var d="application/octet-stream";h.prototype._isSafari()&&(d="text/plain");var e=new Blob(a,{type:d}),f=window.URL.createObjectURL(e);h.prototype.downloadFile(f,b,c)},h.prototype.downloadFile=function(a,b,c){var d=f(b,c),e=d[0],i=d[1],j=document.createElement("a");if(j.href=a,j.download=e,j.onclick=g,j.style.display="none",document.body.appendChild(j),h.prototype._isSafari()){var k="Hello, Safari user! To download this file...\n";k+="1. Go to File --> Save As.\n",k+='2. Choose "Page Source" as the Format.\n',k+='3. Name it with this extension: ."'+i+'"',alert(k)}j.click(),a=null},h.prototype._checkFileExtension=f, +h.prototype._isSafari=function(){var a=Object.prototype.toString.call(window.HTMLElement);return a.indexOf("Constructor")>0},h}({},amdclean.core_core,amdclean.reqwest,amdclean.core_error_helpers),amdclean.events_keyboard=function(a,b){"use strict";var c=b,d={};return c.prototype.isKeyPressed=!1,c.prototype.keyIsPressed=!1,c.prototype.key="",c.prototype.keyCode=0,c.prototype._onkeydown=function(a){this._setProperty("isKeyPressed",!0),this._setProperty("keyIsPressed",!0),this._setProperty("keyCode",a.which),d[a.which]=!0;var b=String.fromCharCode(a.which);b||(b=a.which),this._setProperty("key",b);var c=this.keyPressed||window.keyPressed;if("function"==typeof c&&!a.charCode){var e=c(a);e===!1&&a.preventDefault()}},c.prototype._onkeyup=function(a){var b=this.keyReleased||window.keyReleased;this._setProperty("isKeyPressed",!1),this._setProperty("keyIsPressed",!1),d[a.which]=!1;var c=String.fromCharCode(a.which);if(c||(c=a.which),this._setProperty("key",c),this._setProperty("keyCode",a.which),"function"==typeof b){var e=b(a);e===!1&&a.preventDefault()}},c.prototype._onkeypress=function(a){this._setProperty("keyCode",a.which),this._setProperty("key",String.fromCharCode(a.which));var b=this.keyTyped||window.keyTyped;if("function"==typeof b){var c=b(a);c===!1&&a.preventDefault()}},c.prototype._onblur=function(a){d={}},c.prototype.keyIsDown=function(a){return d[a]},c}({},amdclean.core_core),amdclean.events_acceleration=function(a,b){"use strict";var c=b;c.prototype.deviceOrientation=void 0,c.prototype.accelerationX=0,c.prototype.accelerationY=0,c.prototype.accelerationZ=0,c.prototype.pAccelerationX=0,c.prototype.pAccelerationY=0,c.prototype.pAccelerationZ=0,c.prototype._updatePAccelerations=function(){this._setProperty("pAccelerationX",this.accelerationX),this._setProperty("pAccelerationY",this.accelerationY),this._setProperty("pAccelerationZ",this.accelerationZ)};var d=.5;c.prototype.setMoveThreshold=function(a){"number"==typeof a&&(d=a)};var e="",f="";return c.prototype._ondeviceorientation=function(a){this._setProperty("accelerationX",a.beta),this._setProperty("accelerationY",a.gamma),this._setProperty("accelerationZ",a.alpha),this._handleMotion()},c.prototype._ondevicemotion=function(a){this._setProperty("accelerationX",2*a.acceleration.x),this._setProperty("accelerationY",2*a.acceleration.y),this._setProperty("accelerationZ",2*a.acceleration.z),this._handleMotion()},c.prototype._onMozOrientation=function(a){this._setProperty("accelerationX",a.x),this._setProperty("accelerationY",a.y),this._setProperty("accelerationZ",a.z),this._handleMotion()},c.prototype._handleMotion=function(){90===window.orientation||-90===window.orientation?this._setProperty("deviceOrientation","landscape"):0===window.orientation?this._setProperty("deviceOrientation","portrait"):void 0===window.orientation&&this._setProperty("deviceOrientation","undefined");var a=this.onDeviceMove||window.onDeviceMove;"function"==typeof a&&(Math.abs(this.accelerationX-this.pAccelerationX)>d||Math.abs(this.accelerationY-this.pAccelerationY)>d||Math.abs(this.accelerationZ-this.pAccelerationZ)>d)&&a();var b=this.onDeviceTurn||window.onDeviceTurn;if("function"==typeof b){var c=0;Math.abs(this.accelerationX)>c&&(c=this.accelerationX,f="x"),Math.abs(this.accelerationY)>c&&(c=this.accelerationY,f="y"),Math.abs(this.accelerationZ)>c&&(f="z"),""!==e&&e!==f&&b(f),e=f}},c}({},amdclean.core_core),amdclean.events_mouse=function(a,b,c){"use strict";function d(a,b){var c=a.getBoundingClientRect();return{x:b.clientX-c.left,y:b.clientY-c.top}}var e=b,f=c;return e.prototype.mouseX=0,e.prototype.mouseY=0,e.prototype.pmouseX=0,e.prototype.pmouseY=0,e.prototype.winMouseX=0,e.prototype.winMouseY=0,e.prototype.pwinMouseX=0,e.prototype.pwinMouseY=0,e.prototype.mouseButton=0,e.prototype.mouseIsPressed=!1,e.prototype.isMousePressed=!1,e.prototype._updateMouseCoords=function(a){if("touchstart"===a.type||"touchmove"===a.type||"touchend"===a.type)this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY);else if(null!==this._curElement){var b=d(this._curElement.elt,a);this._setProperty("mouseX",b.x),this._setProperty("mouseY",b.y)}this._setProperty("winMouseX",a.pageX),this._setProperty("winMouseY",a.pageY)},e.prototype._updatePMouseCoords=function(a){this._setProperty("pmouseX",this.mouseX),this._setProperty("pmouseY",this.mouseY),this._setProperty("pwinMouseX",this.winMouseX),this._setProperty("pwinMouseY",this.winMouseY)},e.prototype._setMouseButton=function(a){1===a.button?this._setProperty("mouseButton",f.CENTER):2===a.button?this._setProperty("mouseButton",f.RIGHT):(this._setProperty("mouseButton",f.LEFT),("touchstart"===a.type||"touchmove"===a.type)&&(this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY)))},e.prototype._onmousemove=function(a){var b,c=this._isGlobal?window:this;this._updateMouseCoords(a),this.isMousePressed?"function"==typeof c.mouseDragged?(b=c.mouseDragged(a),b===!1&&a.preventDefault()):"function"==typeof c.touchMoved&&(b=c.touchMoved(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a)):"function"==typeof c.mouseMoved&&(b=c.mouseMoved(a),b===!1&&a.preventDefault())},e.prototype._onmousedown=function(a){var b,c=this._isGlobal?window:this;this._setProperty("isMousePressed",!0),this._setProperty("mouseIsPressed",!0),this._setMouseButton(a),this._updateMouseCoords(a),"function"==typeof c.mousePressed?(b=c.mousePressed(a),b===!1&&a.preventDefault()):"function"==typeof c.touchStarted&&(b=c.touchStarted(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a))},e.prototype._onmouseup=function(a){var b,c=this._isGlobal?window:this;this._setProperty("isMousePressed",!1),this._setProperty("mouseIsPressed",!1),"function"==typeof c.mouseReleased?(b=c.mouseReleased(a),b===!1&&a.preventDefault()):"function"==typeof c.touchEnded&&(b=c.touchEnded(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a))},e.prototype._onclick=function(a){var b=this._isGlobal?window:this;if("function"==typeof b.mouseClicked){var c=b.mouseClicked(a);c===!1&&a.preventDefault()}},e.prototype._onmousewheel=e.prototype._onDOMMouseScroll=function(a){var b=this._isGlobal?window:this;if("function"==typeof b.mouseWheel){a.delta=Math.max(-1,Math.min(1,a.wheelDelta||-a.detail));var c=b.mouseWheel(a);c===!1&&a.preventDefault()}},e}({},amdclean.core_core,amdclean.core_constants),amdclean.utilities_time_date=function(a,b){"use strict";var c=b;return c.prototype.day=function(){return(new Date).getDate()},c.prototype.hour=function(){return(new Date).getHours()},c.prototype.minute=function(){return(new Date).getMinutes()},c.prototype.millis=function(){return window.performance.now()},c.prototype.month=function(){return(new Date).getMonth()+1},c.prototype.second=function(){return(new Date).getSeconds()},c.prototype.year=function(){return(new Date).getFullYear()},c}({},amdclean.core_core),amdclean.events_touch=function(a,b){"use strict";function c(a,b,c){c=c||0;var d=a.getBoundingClientRect(),e=b.touches[c]||b.changedTouches[c];return{x:e.clientX-d.left,y:e.clientY-d.top}}var d=b;return d.prototype.touchX=0,d.prototype.touchY=0,d.prototype.ptouchX=0,d.prototype.ptouchY=0,d.prototype.touches=[],d.prototype.touchIsDown=!1,d.prototype._updateTouchCoords=function(a){if("mousedown"===a.type||"mousemove"===a.type||"mouseup"===a.type)this._setProperty("touchX",this.mouseX),this._setProperty("touchY",this.mouseY);else{var b=c(this._curElement.elt,a,0);this._setProperty("touchX",b.x),this._setProperty("touchY",b.y);for(var d=[],e=0;e>>0},getSeed:function(){return a},rand:function(){return b=(d*b+e)%c,b/c}}}();c.prototype.randomSeed=function(a){e.setSeed(a),d=!0},c.prototype.random=function(a,b){var c;if(c=d?e.rand():Math.random(),0===arguments.length)return c;if(1===arguments.length)return c*a;if(a>b){var f=a;a=b,b=f}return c*(b-a)+a};var f,g=!1;return c.prototype.randomGaussian=function(a,b){var c,d,e,h;if(g)c=f,g=!1;else{do d=this.random(2)-1,e=this.random(2)-1,h=d*d+e*e;while(h>=1);h=Math.sqrt(-2*Math.log(h)/h),c=d*h,f=e*h,g=!0}var i=a||0,j=b||1;return c*j+i},c}({},amdclean.core_core),amdclean.math_noise=function(a,b){"use strict";for(var c=b,d=4,e=1<p;p++)m[p]=Math.sin(p*o*k),n[p]=Math.cos(p*o*k);var q=l;q>>=1;var r;return c.prototype.noise=function(a,b,c){if(b=b||0,c=c||0,null==r){r=new Array(h+1);for(var k=0;h+1>k;k++)r[k]=Math.random()}0>a&&(a=-a),0>b&&(b=-b),0>c&&(c=-c);for(var m,o,p,s,t,u=Math.floor(a),v=Math.floor(b),w=Math.floor(c),x=a-u,y=b-v,z=c-w,A=0,B=.5,C=function(a){return.5*(1-n[Math.floor(a*q)%l])},D=0;i>D;D++){var E=u+(v<=1&&(u++,x--),y>=1&&(v++,y--),z>=1&&(w++,z--)}return A},c.prototype.noiseDetail=function(a,b){a>0&&(i=a),b>0&&(j=b)},c.prototype.noiseSeed=function(a){var b=function(){var a,b,c=4294967296,d=1664525,e=1013904223;return{setSeed:function(d){b=a=(null==d?Math.random()*c:d)>>>0},getSeed:function(){return a},rand:function(){return b=(d*b+e)%c,b/c}}}();b.setSeed(a),r=new Array(h+1);for(var c=0;h+1>c;c++)r[c]=b.rand()},c}({},amdclean.core_core),amdclean.math_trigonometry=function(a,b,c,d){"use strict";var e=b,f=c,g=d;return e.prototype._angleMode=g.RADIANS,e.prototype.acos=function(a){return this._angleMode===g.RADIANS?Math.acos(a):f.radiansToDegrees(Math.acos(a))},e.prototype.asin=function(a){return this._angleMode===g.RADIANS?Math.asin(a):f.radiansToDegrees(Math.asin(a))},e.prototype.atan=function(a){return this._angleMode===g.RADIANS?Math.atan(a):f.radiansToDegrees(Math.atan(a))},e.prototype.atan2=function(a,b){return this._angleMode===g.RADIANS?Math.atan2(a,b):f.radiansToDegrees(Math.atan2(a,b))},e.prototype.cos=function(a){return this._angleMode===g.RADIANS?Math.cos(a):Math.cos(this.radians(a))},e.prototype.sin=function(a){return this._angleMode===g.RADIANS?Math.sin(a):Math.sin(this.radians(a))},e.prototype.tan=function(a){return this._angleMode===g.RADIANS?Math.tan(a):Math.tan(this.radians(a))},e.prototype.degrees=function(a){return f.radiansToDegrees(a)},e.prototype.radians=function(a){return f.degreesToRadians(a)},e.prototype.angleMode=function(a){(a===g.DEGREES||a===g.RADIANS)&&(this._angleMode=a)},e}({},amdclean.core_core,amdclean.math_polargeometry,amdclean.core_constants),amdclean._3d_shaders=function(a){return{texLightVert:["uniform mat4 modelviewMatrix;","uniform mat4 transformMatrix;","uniform mat3 normalMatrix;","uniform mat4 texMatrix;","uniform int lightCount;","uniform vec4 lightPosition[8];","uniform vec3 lightNormal[8];","uniform vec3 lightAmbient[8];","uniform vec3 lightDiffuse[8];","uniform vec3 lightSpecular[8];","uniform vec3 lightFalloff[8];","uniform vec2 lightSpot[8];","attribute vec4 position;","attribute vec4 color;","attribute vec3 normal;","attribute vec2 texCoord;","attribute vec4 ambient;","attribute vec4 specular;","attribute vec4 emissive;","attribute float shininess;","varying vec4 vertColor;","varying vec4 backVertColor;","varying vec4 vertTexCoord;","const float zero_float = 0.0;","const float one_float = 1.0;","const vec3 zero_vec3 = vec3(0);","float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {","vec3 lpv = lightPos - vertPos;","vec3 dist = vec3(one_float);","dist.z = dot(lpv, lpv);","dist.y = sqrt(dist.z);","return one_float / dot(dist, coeff);","}","float spotFactor(vec3 lightPos,vec3 vertPos,","vec3 lightNorm,float minCos,float spotExp) {","vec3 lpv = normalize(lightPos - vertPos);","vec3 nln = -one_float * lightNorm;","float spotCos = dot(nln, lpv);","return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);","}","float lambertFactor(vec3 lightDir, vec3 vecNormal) {","return max(zero_float, dot(lightDir, vecNormal));","}","float blinnPhongFactor(vec3 lightDir,","vec3 vertPos,vec3 vecNormal, float shine) {","vec3 np = normalize(vertPos);","vec3 ldp = normalize(lightDir - np);","return pow(max(zero_float, dot(ldp, vecNormal)), shine);","}","void main() {","gl_Position = transformMatrix * position;","vec3 ecVertex = vec3(modelviewMatrix * position);","vec3 ecNormal = normalize(normalMatrix * normal);","vec3 ecNormalInv = ecNormal * -one_float;","vec3 totalAmbient = vec3(0, 0, 0);","vec3 totalFrontDiffuse = vec3(0, 0, 0);","vec3 totalFrontSpecular = vec3(0, 0, 0);","vec3 totalBackDiffuse = vec3(0, 0, 0);","vec3 totalBackSpecular = vec3(0, 0, 0);","for (int i = 0; i < 8; i++) {","if (lightCount == i) break;","vec3 lightPos = lightPosition[i].xyz;","bool isDir = zero_float < lightPosition[i].w;","float spotCos = lightSpot[i].x;","float spotExp = lightSpot[i].y;","vec3 lightDir;","float falloff;","float spotf;","if (isDir) {","falloff = one_float;","lightDir = -one_float * lightNormal[i];","} else {","falloff = falloffFactor(lightPos, ecVertex, lightFalloff[i]);","lightDir = normalize(lightPos - ecVertex);","}","spotf=spotExp > zero_float ? spotFactor(lightPos,","ecVertex,","lightNormal[i],","spotCos,","spotExp):one_float;","if (any(greaterThan(lightAmbient[i], zero_vec3))) {","totalAmbient+= lightAmbient[i] * falloff;","}","if (any(greaterThan(lightDiffuse[i], zero_vec3))) {","totalFrontDiffuse += lightDiffuse[i] * falloff * spotf *","lambertFactor(lightDir, ecNormal);","totalBackDiffuse += lightDiffuse[i] * falloff * spotf *","lambertFactor(lightDir, ecNormalInv);","}","if (any(greaterThan(lightSpecular[i], zero_vec3))) {","totalFrontSpecular += lightSpecular[i] * falloff * spotf * ","blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess);","totalBackSpecular += lightSpecular[i] * falloff * spotf *","blinnPhongFactor(lightDir, ecVertex, ecNormalInv, shininess);","}","}","vertColor =vec4(totalAmbient, 0) * ambient + ","vec4(totalFrontDiffuse, 1) * color +","vec4(totalFrontSpecular, 0) * specular +","vec4(emissive.rgb, 0);","backVertColor = vec4(totalAmbient, 0) * ambient + ","vec4(totalBackDiffuse, 1) * color +","vec4(totalBackSpecular, 0) * specular +","vec4(emissive.rgb, 0);","vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);","}"].join("\n"),texLightFrag:["precision mediump float;","precision mediump int;","uniform sampler2D texture;","uniform vec2 texOffset;","varying vec4 vertColor;","varying vec4 backVertColor;","varying vec4 vertTexCoord;","void main() {","gl_FragColor = texture2D(texture,vertTexCoord.st)*","(gl_FrontFacing ? vertColor : backVertColor);","}"].join("\n"),testVert:["attribute vec3 position;","attribute vec3 normal;","uniform mat4 modelviewMatrix;","uniform mat4 transformMatrix;","uniform mat4 normalMatrix;","varying vec3 vertexNormal;","void main(void) {","vec3 zeroToOne = position / 1000.0;","vec4 positionVec4 = vec4(zeroToOne, 1.);","gl_Position = transformMatrix * modelviewMatrix * positionVec4;","vertexNormal = vec3( normalMatrix * vec4( normal, 1.0 ) );","}"].join("\n"),testFrag:["precision mediump float;","varying vec3 vertexNormal;","void main(void) {","gl_FragColor = vec4(vertexNormal, 1.0);","}"].join("\n")}}({}),amdclean._3d_p5Matrix=function(a,b,c,d){"use strict";var e=b,f=c,g=d,h="undefined"!=typeof Float32Array?Float32Array:Array;return e.Matrix=function(){return arguments[0]instanceof e?(this.p5=arguments[0],this.mat4=arguments[1]||new h([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])):this.mat4=arguments[0]||new h([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this},e.Matrix.prototype.set=function(a){return a instanceof e.Matrix?(this.mat4=a.mat4,this):a instanceof h?(this.mat4=a,this):this},e.Matrix.prototype.get=function(){return new e.Matrix(this.mat4)},e.Matrix.prototype.copy=function(){var a=new e.Matrix;return a.mat4[0]=this.mat4[0],a.mat4[1]=this.mat4[1],a.mat4[2]=this.mat4[2],a.mat4[3]=this.mat4[3],a.mat4[4]=this.mat4[4],a.mat4[5]=this.mat4[5],a.mat4[6]=this.mat4[6],a.mat4[7]=this.mat4[7],a.mat4[8]=this.mat4[8],a.mat4[9]=this.mat4[9],a.mat4[10]=this.mat4[10],a.mat4[11]=this.mat4[11],a.mat4[12]=this.mat4[12],a.mat4[13]=this.mat4[13],a.mat4[14]=this.mat4[14],a.mat4[15]=this.mat4[15],a},e.Matrix.identity=function(){return new e.Matrix},e.Matrix.prototype.transpose=function(a){var b,c,d,f,g,i;return a instanceof e.Matrix?(b=a.mat4[1],c=a.mat4[2],d=a.mat4[3],f=a.mat4[6],g=a.mat4[7],i=a.mat4[11],this.mat4[0]=a.mat4[0],this.mat4[1]=a.mat4[4],this.mat4[2]=a.mat4[8],this.mat4[3]=a.mat4[12],this.mat4[4]=b,this.mat4[5]=a.mat4[5],this.mat4[6]=a.mat4[9],this.mat4[7]=a.mat4[13],this.mat4[8]=c,this.mat4[9]=f,this.mat4[10]=a.mat4[10],this.mat4[11]=a.mat4[14],this.mat4[12]=d,this.mat4[13]=g,this.mat4[14]=i,this.mat4[15]=a.mat4[15]):a instanceof h&&(b=a[1],c=a[2],d=a[3],f=a[6],g=a[7],i=a[11],this.mat4[0]=a[0],this.mat4[1]=a[4],this.mat4[2]=a[8],this.mat4[3]=a[12],this.mat4[4]=b,this.mat4[5]=a[5],this.mat4[6]=a[9],this.mat4[7]=a[13],this.mat4[8]=c,this.mat4[9]=f,this.mat4[10]=a[10],this.mat4[11]=a[14],this.mat4[12]=d,this.mat4[13]=g,this.mat4[14]=i,this.mat4[15]=a[15]),this},e.Matrix.prototype.invert=function(a){var b,c,d,f,g,i,j,k,l,m,n,o,p,q,r,s;a instanceof e.Matrix?(b=a.mat4[0],c=a.mat4[1],d=a.mat4[2],f=a.mat4[3],g=a.mat4[4],i=a.mat4[5],j=a.mat4[6],k=a.mat4[7],l=a.mat4[8],m=a.mat4[9],n=a.mat4[10],o=a.mat4[11],p=a.mat4[12],q=a.mat4[13],r=a.mat4[14],s=a.mat4[15]):a instanceof h&&(b=a[0],c=a[1],d=a[2],f=a[3],g=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15]);var t=b*i-c*g,u=b*j-d*g,v=b*k-f*g,w=c*j-d*i,x=c*k-f*i,y=d*k-f*j,z=l*q-m*p,A=l*r-n*p,B=l*s-o*p,C=m*r-n*q,D=m*s-o*q,E=n*s-o*r,F=t*E-u*D+v*C+w*B-x*A+y*z;return F?(F=1/F,this.mat4[0]=(i*E-j*D+k*C)*F,this.mat4[1]=(d*D-c*E-f*C)*F,this.mat4[2]=(q*y-r*x+s*w)*F,this.mat4[3]=(n*x-m*y-o*w)*F,this.mat4[4]=(j*B-g*E-k*A)*F,this.mat4[5]=(b*E-d*B+f*A)*F,this.mat4[6]=(r*v-p*y-s*u)*F,this.mat4[7]=(l*y-n*v+o*u)*F,this.mat4[8]=(g*D-i*B+k*z)*F,this.mat4[9]=(c*B-b*D-f*z)*F,this.mat4[10]=(p*x-q*v+s*t)*F,this.mat4[11]=(m*v-l*x-o*t)*F,this.mat4[12]=(i*A-g*C-j*z)*F,this.mat4[13]=(b*C-c*A+d*z)*F,this.mat4[14]=(q*u-p*w-r*t)*F,this.mat4[15]=(l*w-m*u+n*t)*F,this):null},e.Matrix.prototype.determinant=function(){var a=this.mat4[0]*this.mat4[5]-this.mat4[1]*this.mat4[4],b=this.mat4[0]*this.mat4[6]-this.mat4[2]*this.mat4[4],c=this.mat4[0]*this.mat4[7]-this.mat4[3]*this.mat4[4],d=this.mat4[1]*this.mat4[6]-this.mat4[2]*this.mat4[5],e=this.mat4[1]*this.mat4[7]-this.mat4[3]*this.mat4[5],f=this.mat4[2]*this.mat4[7]-this.mat4[3]*this.mat4[6],g=this.mat4[8]*this.mat4[13]-this.mat4[9]*this.mat4[12],h=this.mat4[8]*this.mat4[14]-this.mat4[10]*this.mat4[12],i=this.mat4[8]*this.mat4[15]-this.mat4[11]*this.mat4[12],j=this.mat4[9]*this.mat4[14]-this.mat4[10]*this.mat4[13],k=this.mat4[9]*this.mat4[15]-this.mat4[11]*this.mat4[13],l=this.mat4[10]*this.mat4[15]-this.mat4[11]*this.mat4[14];return a*l-b*k+c*j+d*i-e*h+f*g},e.Matrix.prototype.mult=function(a){var b=new h(16),c=new h(16);a instanceof e.Matrix?c=a.mat4:a instanceof h&&(c=a);var d=this.mat4[0],f=this.mat4[1],g=this.mat4[2],i=this.mat4[3];return b[0]=d*c[0]+f*c[4]+g*c[8]+i*c[12],b[1]=d*c[1]+f*c[5]+g*c[9]+i*c[13],b[2]=d*c[2]+f*c[6]+g*c[10]+i*c[14],b[3]=d*c[3]+f*c[7]+g*c[11]+i*c[15],d=this.mat4[4],f=this.mat4[5],g=this.mat4[6],i=this.mat4[7],b[4]=d*c[0]+f*c[4]+g*c[8]+i*c[12],b[5]=d*c[1]+f*c[5]+g*c[9]+i*c[13],b[6]=d*c[2]+f*c[6]+g*c[10]+i*c[14],b[7]=d*c[3]+f*c[7]+g*c[11]+i*c[15],d=this.mat4[8],f=this.mat4[9],g=this.mat4[10],i=this.mat4[11],b[8]=d*c[0]+f*c[4]+g*c[8]+i*c[12],b[9]=d*c[1]+f*c[5]+g*c[9]+i*c[13],b[10]=d*c[2]+f*c[6]+g*c[10]+i*c[14],b[11]=d*c[3]+f*c[7]+g*c[11]+i*c[15],d=this.mat4[12],f=this.mat4[13],g=this.mat4[14],i=this.mat4[15],b[12]=d*c[0]+f*c[4]+g*c[8]+i*c[12],b[13]=d*c[1]+f*c[5]+g*c[9]+i*c[13],b[14]=d*c[2]+f*c[6]+g*c[10]+i*c[14],b[15]=d*c[3]+f*c[7]+g*c[11]+i*c[15],this.mat4=b,this},e.Matrix.prototype.scale=function(){var a,b,c;arguments[0]instanceof e.Vector?(a=arguments[0].x,b=arguments[0].y,c=arguments[0].z):arguments[0]instanceof Array?(a=arguments[0][0],b=arguments[0][1],c=arguments[0][2]):(a=arguments[0]||1,b=arguments[1]||1,c=arguments[2]||1);for(var d=new h(16),f=0;fb?1:-1,i=b,j=Math.min(d,Math.abs(c-b));j>g;){var k=i+h*Math.min(j,f);e.push(this._createSmallArc(a,i,k)), +j-=Math.abs(k-i),i=k}return e},e.prototype._createSmallArc=function(a,b,c){var d=(c-b)/2,e=a*Math.cos(d),f=a*Math.sin(d),g=e,h=-f,i=.5522847498,j=i*Math.tan(d),k=g+j*f,l=h+j*e,m=k,n=-l,o=d+b,p=Math.cos(o),q=Math.sin(o);return{x1:a*Math.cos(b),y1:a*Math.sin(b),x2:k*p-l*q,y2:k*q+l*p,x3:m*p-n*q,y3:m*q+n*p,x4:a*Math.cos(c),y4:a*Math.sin(c)}},e.prototype.arc=function(a,b,c,d,e,g,h){if(!this._doStroke&&!this._doFill)return this;this._angleMode===f.DEGREES&&(e=this.radians(e),g=this.radians(g));var i=this._createArc(1,e,g);return this._graphics.arc(a,b,c,d,e,g,h,i),this},e.prototype.ellipse=function(a,b,c,d){return this._validateParameters("ellipse",arguments,["Number","Number","Number","Number"]),this._doStroke||this._doFill?(c=Math.abs(c),d=Math.abs(d),this._graphics.ellipse(a,b,c,d),this):this},e.prototype.line=function(){return this._validateParameters("line",arguments,[["Number","Number","Number","Number"],["Number","Number","Number","Number","Number","Number"]]),this._doStroke?void(this._graphics.isP3D?this._graphics.line(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):this._graphics.line(arguments[0],arguments[1],arguments[2],arguments[3])):this},e.prototype.point=function(a,b){return this._validateParameters("point",arguments,["Number","Number"]),this._doStroke?(this._graphics.point(a,b),this):this},e.prototype.quad=function(a,b,c,d,e,f,g,h){return this._validateParameters("quad",arguments,["Number","Number","Number","Number","Number","Number","Number","Number"]),this._doStroke||this._doFill?(this._graphics.quad(a,b,c,d,e,f,g,h),this):this},e.prototype.rect=function(a,b,c,d,e,f,g,h){return this._validateParameters("rect",arguments,[["Number","Number","Number","Number"],["Number","Number","Number","Number","Number"],["Number","Number","Number","Number","Number","Number","Number","Number","Number"]]),this._doStroke||this._doFill?(this._graphics.rect(a,b,c,d,e,f,g,h),this):void 0},e.prototype.triangle=function(a,b,c,d,e,f){return this._validateParameters("triangle",arguments,["Number","Number","Number","Number","Number","Number"]),this._doStroke||this._doFill?(this._graphics.triangle(a,b,c,d,e,f),this):this},e}({},amdclean.core_core,amdclean.core_constants,amdclean.core_error_helpers),amdclean.core_attributes=function(a,b,c){"use strict";var d=b,e=c;return d.prototype._rectMode=e.CORNER,d.prototype._ellipseMode=e.CENTER,d.prototype.ellipseMode=function(a){return(a===e.CORNER||a===e.CORNERS||a===e.RADIUS||a===e.CENTER)&&(this._ellipseMode=a),this},d.prototype.noSmooth=function(){return this._graphics.noSmooth(),this},d.prototype.rectMode=function(a){return(a===e.CORNER||a===e.CORNERS||a===e.RADIUS||a===e.CENTER)&&(this._rectMode=a),this},d.prototype.smooth=function(){return this._graphics.smooth(),this},d.prototype.strokeCap=function(a){return(a===e.ROUND||a===e.SQUARE||a===e.PROJECT)&&this._graphics.strokeCap(a),this},d.prototype.strokeJoin=function(a){return(a===e.ROUND||a===e.BEVEL||a===e.MITER)&&this._graphics.strokeJoin(a),this},d.prototype.strokeWeight=function(a){return this._graphics.strokeWeight(a),this},d}({},amdclean.core_core,amdclean.core_constants),amdclean.core_curves=function(a,b,c){"use strict";var d=b,e=20,f=20;return d.prototype._curveTightness=0,d.prototype.bezier=function(a,b,c,d,e,f,g,h){return this._validateParameters("bezier",arguments,["Number","Number","Number","Number","Number","Number","Number","Number"]),this._doStroke?(this._graphics.bezier(a,b,c,d,e,f,g,h),this):this},d.prototype.bezierDetail=function(a){return e=a,this},d.prototype.bezierPoint=function(a,b,c,d,e){var f=1-e;return Math.pow(f,3)*a+3*Math.pow(f,2)*e*b+3*f*Math.pow(e,2)*c+Math.pow(e,3)*d},d.prototype.bezierTangent=function(a,b,c,d,e){var f=1-e;return 3*d*Math.pow(e,2)-3*c*Math.pow(e,2)+6*c*f*e-6*b*f*e+3*b*Math.pow(f,2)-3*a*Math.pow(f,2)},d.prototype.curve=function(a,b,c,d,e,f,g,h){return this._validateParameters("curve",arguments,["Number","Number","Number","Number","Number","Number","Number","Number"]),this._doStroke?(this._graphics.curve(a,b,c,d,e,f,g,h),this):void 0},d.prototype.curveDetail=function(a){return f=a,this},d.prototype.curveTightness=function(a){this._setProperty("_curveTightness",a)},d.prototype.curvePoint=function(a,b,c,d,e){var f=e*e*e,g=e*e,h=-.5*f+g-.5*e,i=1.5*f-2.5*g+1,j=-1.5*f+2*g+.5*e,k=.5*f-.5*g;return a*h+b*i+c*j+d*k},d.prototype.curveTangent=function(a,b,c,d,e){var f=e*e,g=-3*f/2+2*e-.5,h=9*f/2-5*e,i=-9*f/2+4*e+.5,j=3*f/2-e;return a*g+b*h+c*i+d*j},d}({},amdclean.core_core,amdclean.core_error_helpers),amdclean.core_vertex=function(a,b,c){"use strict";var d=b,e=c,f=null,g=[],h=[],i=!1,j=!1,k=!1,l=!1;return d.prototype.beginContour=function(){return h=[],l=!0,this},d.prototype.beginShape=function(a){return f=a===e.POINTS||a===e.LINES||a===e.TRIANGLES||a===e.TRIANGLE_FAN||a===e.TRIANGLE_STRIP||a===e.QUADS||a===e.QUAD_STRIP?a:null,g=[],h=[],this},d.prototype.bezierVertex=function(a,b,c,d,e,f){if(0===g.length)throw"vertex() must be used once before calling bezierVertex()";i=!0;for(var j=[],k=0;k0))throw"vertex() must be used once before calling quadraticVertex()";k=!0;for(var i=[],j=0;j=e;e++)for(i=e/c,f=0;b>=f;f++)h=f/b,g=a(h,i),this.vertices.push(g);var k,l,m,n,o,p,q,r;for(e=0;c>e;e++)for(f=0;b>f;f++)k=e*j+f+d,l=e*j+f+1+d,m=(e+1)*j+f+1+d,n=(e+1)*j+f+d,o=[f/b,e/c],p=[(f+1)/b,e/c],q=[(f+1)/b,(e+1)/c],r=[f/b,(e+1)/c],this.faces.push([k,l,n]),this.uvs.push([o,p,r]),this.faces.push([l,m,n]),this.uvs.push([p,q,r])},e.Geometry3D.prototype.mergeVertices=function(){var a,b,c,d,e,f={},g=[],h=[],i=4,j=Math.pow(10,i);for(c=0;cm;m++)if(e[m]===e[(m+1)%3]){l=m,k.push(c);break}}for(c=k.length-1;c>=0;c--){var n=k[c];this.faces.splice(n,1)}var o=this.vertices.length-g.length;return this.vertices=g,o},e.Geometry3D.prototype.computeFaceNormals=function(){for(var a=new e.Vector,b=new e.Vector,c=0;c0,"No "+b+" specified.")}var c=[],d=this;b("familyName"),b("weightName"),b("manufacturer"),b("copyright"),b("version"),a(this.unitsPerEm>0,"No unitsPerEm specified.")},d.prototype.toTables=function(){return f.fontToTable(this)},d.prototype.toBuffer=function(){for(var a=this.toTables(),b=a.encode(),c=new ArrayBuffer(b.length),d=new Uint8Array(c),e=0;eD;D+=1){var E=l.getTag(m,C),F=l.getULong(m,C+8);switch(E){case"cmap":k.tables.cmap=n.parse(m,F),k.encoding=new i.CmapEncoding(k.tables.cmap),k.encoding||(k.supported=!1);break;case"head":k.tables.head=r.parse(m,F),k.unitsPerEm=k.tables.head.unitsPerEm,b=k.tables.head.indexToLocFormat;break;case"hhea":k.tables.hhea=s.parse(m,F),k.ascender=k.tables.hhea.ascender,k.descender=k.tables.hhea.descender,k.numberOfHMetrics=k.tables.hhea.numberOfHMetrics;break;case"hmtx":c=F;break;case"maxp":k.tables.maxp=w.parse(m,F),k.numGlyphs=k.tables.maxp.numGlyphs;break;case"name":k.tables.name=x.parse(m,F),k.familyName=k.tables.name.fontFamily,k.styleName=k.tables.name.fontSubfamily;break;case"OS/2":k.tables.os2=y.parse(m,F);break;case"post":k.tables.post=z.parse(m,F),k.glyphNames=new i.GlyphNames(k.tables.post);break;case"glyf":d=F;break;case"loca":e=F;break;case"CFF ":f=F;break;case"kern":g=F;break;case"GPOS":h=F}C+=16}if(d&&e){var G=0===b,H=v.parse(m,e,k.numGlyphs,G);k.glyphs=p.parse(m,d,H,k),t.parse(m,c,k.numberOfHMetrics,k.numGlyphs,k.glyphs),i.addGlyphNames(k)}else f?(o.parse(m,f,k),i.addGlyphNames(k)):k.supported=!1;return k.supported&&(k.kerningPairs=g?u.parse(m,g):{},h&&q.parse(m,h,k)),k}function h(a,b){var c="undefined"==typeof window,d=c?e:f;d(a,function(a,c){if(a)return b(a);var d=g(c);return d.supported?b(null,d):b("Font is not supported (is this a Postscript font?)")})}var i=a("./encoding"),j=a("./font"),k=a("./glyph"),l=a("./parse"),m=a("./path"),n=a("./tables/cmap"),o=a("./tables/cff"),p=a("./tables/glyf"),q=a("./tables/gpos"),r=a("./tables/head"),s=a("./tables/hhea"),t=a("./tables/hmtx"),u=a("./tables/kern"),v=a("./tables/loca"),w=a("./tables/maxp"),x=a("./tables/name"),y=a("./tables/os2"),z=a("./tables/post");c._parse=l,c.Font=j.Font,c.Glyph=k.Glyph,c.Path=m.Path,c.parse=g,c.load=h},{"./encoding":3,"./font":4,"./glyph":5,"./parse":7,"./path":8,"./tables/cff":10,"./tables/cmap":11,"./tables/glyf":12,"./tables/gpos":13,"./tables/head":14,"./tables/hhea":15,"./tables/hmtx":16,"./tables/kern":17,"./tables/loca":18,"./tables/maxp":19,"./tables/name":20,"./tables/os2":21,"./tables/post":22,fs:void 0}],7:[function(a,b,c){"use strict";function d(a,b){this.data=a,this.offset=b,this.relativeOffset=0}c.getByte=function(a,b){return a.getUint8(b)},c.getCard8=c.getByte,c.getUShort=function(a,b){return a.getUint16(b,!1)},c.getCard16=c.getUShort,c.getShort=function(a,b){return a.getInt16(b,!1)},c.getULong=function(a,b){return a.getUint32(b,!1)},c.getFixed=function(a,b){var c=a.getInt16(b,!1),d=a.getUint16(b+2,!1);return c+d/65535},c.getTag=function(a,b){for(var c="",d=b;b+4>d;d+=1)c+=String.fromCharCode(a.getInt8(d));return c},c.getOffset=function(a,b,c){for(var d=0,e=0;c>e;e+=1)d<<=8,d+=a.getUint8(b+e);return d},c.getBytes=function(a,b,c){for(var d=[],e=b;c>e;e+=1)d.push(a.getUint8(e));return d},c.bytesToString=function(a){for(var b="",c=0;cf;f++)b[f]=c.getUShort(d,e),e+=2;return this.relativeOffset+=2*a,b},d.prototype.parseString=function(a){var b=this.data,c=this.offset+this.relativeOffset,d="";this.relativeOffset+=a;for(var e=0;a>e;e++)d+=String.fromCharCode(b.getUint8(c+e));return d},d.prototype.parseTag=function(){return this.parseString(4)},d.prototype.parseLongDateTime=function(){var a=c.getULong(this.data,this.offset+this.relativeOffset+4);return this.relativeOffset+=8,a},d.prototype.parseFixed=function(){var a=c.getULong(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,a/65536},d.prototype.parseVersion=function(){var a=c.getUShort(this.data,this.offset+this.relativeOffset),b=c.getUShort(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,a+b/4096/10},d.prototype.skip=function(a,b){void 0===b&&(b=1),this.relativeOffset+=e[a]*b},c.Parser=d},{}],8:[function(a,b,c){"use strict";function d(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}d.prototype.moveTo=function(a,b){this.commands.push({type:"M",x:a,y:b})},d.prototype.lineTo=function(a,b){this.commands.push({type:"L",x:a,y:b})},d.prototype.curveTo=d.prototype.bezierCurveTo=function(a,b,c,d,e,f){this.commands.push({type:"C",x1:a,y1:b,x2:c,y2:d,x:e,y:f})},d.prototype.quadTo=d.prototype.quadraticCurveTo=function(a,b,c,d){this.commands.push({type:"Q",x1:a,y1:b,x:c,y:d})},d.prototype.close=d.prototype.closePath=function(){this.commands.push({type:"Z"})},d.prototype.extend=function(a){a.commands&&(a=a.commands),Array.prototype.push.apply(this.commands,a)},d.prototype.draw=function(a){a.beginPath();for(var b=0;b=0&&c>0&&(a+=" "),a+=b(d)}return a}a=void 0!==a?a:2;for(var d="",e=0;ed;d+=1)g.push(J.getOffset(a,k,j)),k+=j;f=e+g[i]}else f=b+2;for(d=0;d>4,g=15&e;if(f===c)break;if(b+=d[f],g===c)break;b+=d[g]}return parseFloat(b)}function g(a,b){var c,d,e,g;if(28===b)return c=a.parseByte(),d=a.parseByte(),c<<8|d;if(29===b)return c=a.parseByte(),d=a.parseByte(),e=a.parseByte(),g=a.parseByte(),c<<24|d<<16|e<<8|g;if(30===b)return f(a);if(b>=32&&246>=b)return b-139;if(b>=247&&250>=b)return c=a.parseByte(),256*(b-247)+c+108;if(b>=251&&254>=b)return c=a.parseByte(),256*-(b-251)-c-108;throw new Error("Invalid b0 "+b)}function h(a){for(var b={},c=0;c=i?(12===i&&(i=1200+d.parseByte()),e.push([i,f]),f=[]):f.push(g(d,i))}return h(e)}function j(a,b){return b=390>=b?H.cffStandardStrings[b]:a[b-391]}function k(a,b,c){for(var d={},e=0;ee;e+=1)f=h.parseSID(),i.push(j(d,f));else if(1===k)for(;i.length<=c;)for(f=h.parseSID(),g=h.parseCard8(),e=0;g>=e;e+=1)i.push(j(d,f)),f+=1;else{if(2!==k)throw new Error("Unknown charset format "+k);for(;i.length<=c;)for(f=h.parseSID(),g=h.parseCard16(),e=0;g>=e;e+=1)i.push(j(d,f)),f+=1}return i}function p(a,b,c){var d,e,f={},g=new J.Parser(a,b),h=g.parseCard8();if(0===h){var i=g.parseCard8();for(d=0;i>d;d+=1)e=g.parseCard8(),f[e]=d}else{if(1!==h)throw new Error("Unknown encoding format "+h);var j=g.parseCard8();for(e=1,d=0;j>d;d+=1)for(var k=g.parseCard8(),l=g.parseCard8(),m=k;k+l>=m;m+=1)f[m]=e,e+=1}return new H.CffEncoding(f,c)}function q(a,b,c){function d(a,b){p&&k.closePath(),k.moveTo(a,b),p=!0}function e(){var a;a=l.length%2!==0,a&&!n&&(o=l.shift()+b.nominalWidthX),m+=l.length>>1,l.length=0,n=!0}function f(a){for(var s,t,u,v,w,x,y,z,A,B,C,D,E=0;E1&&!n&&(o=l.shift()+b.nominalWidthX,n=!0),r+=l.pop(),d(q,r);break;case 5:for(;l.length>0;)q+=l.shift(),r+=l.shift(),k.lineTo(q,r);break;case 6:for(;l.length>0&&(q+=l.shift(),k.lineTo(q,r),0!==l.length);)r+=l.shift(),k.lineTo(q,r);break;case 7:for(;l.length>0&&(r+=l.shift(),k.lineTo(q,r),0!==l.length);)q+=l.shift(),k.lineTo(q,r);break;case 8:for(;l.length>0;)g=q+l.shift(),h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),q=i+l.shift(),r=j+l.shift(),k.curveTo(g,h,i,j,q,r);break;case 10:w=l.pop()+b.subrsBias,x=b.subrs[w],x&&f(x);break;case 11:return;case 12:switch(F=a[E],E+=1,F){case 35:g=q+l.shift(),h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),y=i+l.shift(),z=j+l.shift(),A=y+l.shift(),B=z+l.shift(),C=A+l.shift(),D=B+l.shift(),q=C+l.shift(),r=D+l.shift(),l.shift(),k.curveTo(g,h,i,j,y,z),k.curveTo(A,B,C,D,q,r);break;case 34:g=q+l.shift(),h=r,i=g+l.shift(),j=h+l.shift(),y=i+l.shift(),z=j,A=y+l.shift(),B=j,C=A+l.shift(),D=r,q=C+l.shift(),k.curveTo(g,h,i,j,y,z),k.curveTo(A,B,C,D,q,r);break;case 36:g=q+l.shift(),h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),y=i+l.shift(),z=j,A=y+l.shift(),B=j,C=A+l.shift(),D=B+l.shift(),q=C+l.shift(),k.curveTo(g,h,i,j,y,z),k.curveTo(A,B,C,D,q,r);break;case 37:g=q+l.shift(),h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),y=i+l.shift(),z=j+l.shift(),A=y+l.shift(),B=z+l.shift(),C=A+l.shift(),D=B+l.shift(),Math.abs(C-q)>Math.abs(D-r)?q=C+l.shift():r=D+l.shift(),k.curveTo(g,h,i,j,y,z),k.curveTo(A,B,C,D,q,r);break;default:console.log("Glyph "+c+": unknown operator 1200"+F),l.length=0}break;case 14:l.length>0&&!n&&(o=l.shift()+b.nominalWidthX,n=!0),p&&(k.closePath(),p=!1);break;case 18:e();break;case 19:case 20:e(),E+=m+7>>3;break;case 21:l.length>2&&!n&&(o=l.shift()+b.nominalWidthX,n=!0),r+=l.pop(),q+=l.pop(),d(q,r);break;case 22:l.length>1&&!n&&(o=l.shift()+b.nominalWidthX,n=!0),q+=l.pop(),d(q,r);break;case 23:e();break;case 24:for(;l.length>2;)g=q+l.shift(),h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),q=i+l.shift(),r=j+l.shift(),k.curveTo(g,h,i,j,q,r);q+=l.shift(),r+=l.shift(),k.lineTo(q,r);break;case 25:for(;l.length>6;)q+=l.shift(),r+=l.shift(),k.lineTo(q,r);g=q+l.shift(),h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),q=i+l.shift(),r=j+l.shift(),k.curveTo(g,h,i,j,q,r);break;case 26:for(l.length%2&&(q+=l.shift());l.length>0;)g=q,h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),q=i,r=j+l.shift(),k.curveTo(g,h,i,j,q,r);break;case 27:for(l.length%2&&(r+=l.shift());l.length>0;)g=q+l.shift(),h=r,i=g+l.shift(),j=h+l.shift(),q=i+l.shift(),r=j,k.curveTo(g,h,i,j,q,r);break;case 28:s=a[E],t=a[E+1],l.push((s<<24|t<<16)>>16),E+=2;break;case 29:w=l.pop()+b.gsubrsBias,x=b.gsubrs[w],x&&f(x);break;case 30:for(;l.length>0&&(g=q,h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),q=i+l.shift(),r=j+(1===l.length?l.shift():0),k.curveTo(g,h,i,j,q,r),0!==l.length);)g=q+l.shift(),h=r,i=g+l.shift(),j=h+l.shift(),r=j+l.shift(),q=i+(1===l.length?l.shift():0),k.curveTo(g,h,i,j,q,r);break;case 31:for(;l.length>0&&(g=q+l.shift(),h=r,i=g+l.shift(),j=h+l.shift(),r=j+l.shift(),q=i+(1===l.length?l.shift():0),k.curveTo(g,h,i,j,q,r),0!==l.length);)g=q,h=r+l.shift(),i=g+l.shift(),j=h+l.shift(),q=i+l.shift(),r=j+(1===l.length?l.shift():0),k.curveTo(g,h,i,j,q,r);break;default:32>F?console.log("Glyph "+c+": unknown operator "+F):247>F?l.push(F-139):251>F?(s=a[E],E+=1,l.push(256*(F-247)+s+108)):255>F?(s=a[E],E+=1,l.push(256*-(F-251)-s-108)):(s=a[E],t=a[E+1],u=a[E+2],v=a[E+3],E+=4,l.push((s<<24|t<<16|u<<8|v)/65536))}}}var g,h,i,j,k=new K.Path,l=[],m=0,n=!1,o=b.defaultWidthX,p=!1,q=0,r=0;f(a);var s=new I.Glyph({font:b,index:c});return s.path=k,s.advanceWidth=o,s}function r(a){var b;return b=a.length<1240?107:a.length<33900?1131:32768}function s(a,b,c){c.tables.cff={};var d=l(a,b),f=e(a,d.endOffset,J.bytesToString),g=e(a,f.endOffset),h=e(a,g.endOffset,J.bytesToString),i=e(a,h.endOffset);c.gsubrs=i.objects,c.gsubrsBias=r(c.gsubrs);var j=new DataView(new Uint8Array(g.objects[0]).buffer),k=m(j,h.objects);c.tables.cff.topDict=k;var s=b+k["private"][1],t=n(a,s,k["private"][0],h.objects);if(c.defaultWidthX=t.defaultWidthX,c.nominalWidthX=t.nominalWidthX,0!==t.subrs){var u=s+t.subrs,v=e(a,u);c.subrs=v.objects,c.subrsBias=r(c.subrs)}else c.subrs=[],c.subrsBias=0;var w=e(a,b+k.charStrings);c.nGlyphs=w.objects.length;var x=o(a,b+k.charset,c.nGlyphs,h.objects);c.cffEncoding=0===k.encoding?new H.CffEncoding(H.cffStandardEncoding,x):1===k.encoding?new H.CffEncoding(H.cffExpertEncoding,x):p(a,b+k.encoding,x),c.encoding=c.encoding||c.cffEncoding,c.glyphs=[];for(var y=0;y=0&&(c=d),d=b.indexOf(a),d>=0?c=d+H.cffStandardStrings.length:(c=H.cffStandardStrings.length+b.length,b.push(a)),c}function u(){return new L.Table("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function v(a){var b=new L.Table("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);b.names=[];for(var c=0;c>1,j.skip("uShort",3),d.glyphIndexMap={};var l=new i.Parser(a,b+e+14),m=new i.Parser(a,b+e+16+2*k),n=new i.Parser(a,b+e+16+4*k),o=new i.Parser(a,b+e+16+6*k),p=b+e+16+8*k;for(c=0;k-1>c;c+=1)for(var q,r=l.parseUShort(),s=m.parseUShort(),t=n.parseShort(),u=o.parseUShort(),v=s;r>=v;v+=1)0!==u?(p=o.offset+o.relativeOffset-2,p+=u,p+=2*(v-s),q=i.getUShort(a,p),0!==q&&(q=q+t&65535)):q=v+t&65535,d.glyphIndexMap[v]=q;return d}function e(a,b,c){a.segments.push({end:b,start:b,delta:-(b-c),offset:0})}function f(a){a.segments.push({end:65535,start:65535,delta:1,offset:0})}function g(a){var b,c=new j.Table("cmap",[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:1},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:12},{name:"format",type:"USHORT",value:4},{name:"length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);for(c.segments=[],b=0;bb;b+=1){var o=c.segments[b];i=i.concat({name:"end_"+b,type:"USHORT",value:o.end}),k=k.concat({name:"start_"+b,type:"USHORT",value:o.start}),l=l.concat({name:"idDelta_"+b,type:"SHORT",value:o.delta}),m=m.concat({name:"idRangeOffset_"+b,type:"USHORT",value:o.offset}),void 0!==o.glyphId&&(n=n.concat({name:"glyph_"+b,type:"USHORT",value:o.glyphId}))}return c.fields=c.fields.concat(i),c.fields.push({name:"reservedPad",type:"USHORT",value:0}),c.fields=c.fields.concat(k),c.fields=c.fields.concat(l),c.fields=c.fields.concat(m),c.fields=c.fields.concat(n),c.length=14+2*i.length+2+2*k.length+2*l.length+2*m.length+2*n.length,c}var h=a("../check"),i=a("../parse"),j=a("../table");c.parse=d,c.make=g},{"../check":1,"../parse":7,"../table":9}],12:[function(a,b,c){"use strict";function d(a,b,c,d,e){var f;return(b&d)>0?(f=a.parseByte(),0===(b&e)&&(f=-f),f=c+f):f=(b&e)>0?c:c+a.parseShort(),f}function e(a,b,c,e){var f=new l.Parser(a,b),g=new k.Glyph({font:e,index:c});g.numberOfContours=f.parseShort(),g.xMin=f.parseShort(),g.yMin=f.parseShort(),g.xMax=f.parseShort(),g.yMax=f.parseShort();var h,i;if(g.numberOfContours>0){var m,n=g.endPointIndices=[];for(m=0;mm;m+=1)if(i=f.parseByte(),h.push(i),(8&i)>0)for(var p=f.parseByte(),q=0;p>q;q+=1)h.push(i),m+=1;if(j.argument(h.length===o,"Bad flags."),n.length>0){var r,s=[];if(o>0){for(m=0;o>m;m+=1)i=h[m],r={},r.onCurve=!!(1&i),r.lastPointOfContour=n.indexOf(m)>=0,s.push(r);var t=0;for(m=0;o>m;m+=1)i=h[m],r=s[m],r.x=d(f,i,t,2,16),t=r.x;var u=0;for(m=0;o>m;m+=1)i=h[m],r=s[m],r.y=d(f,i,u,4,32),u=r.y}g.points=s}else g.points=[]}else if(0===g.numberOfContours)g.points=[];else{g.isComposite=!0,g.points=[],g.components=[];for(var v=!0;v;){h=f.parseUShort();var w={glyphIndex:f.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(1&h)>0?(w.dx=f.parseShort(),w.dy=f.parseShort()):(w.dx=f.parseChar(),w.dy=f.parseChar()),(8&h)>0?w.xScale=w.yScale=f.parseF2Dot14():(64&h)>0?(w.xScale=f.parseF2Dot14(),w.yScale=f.parseF2Dot14()):(128&h)>0&&(w.xScale=f.parseF2Dot14(),w.scale01=f.parseF2Dot14(),w.scale10=f.parseF2Dot14(),w.yScale=f.parseF2Dot14()),g.components.push(w),v=!!(32&h)}}return g}function f(a,b){for(var c=[],d=0;df;f++)e[c.parseTag()]={offset:c.parseUShort()};return e}function e(a,b){var c=new k.Parser(a,b),d=c.parseUShort(),e=c.parseUShort();if(1===d)return c.parseUShortList(e);if(2===d){for(var f=[];e--;)for(var g=c.parseUShort(),h=c.parseUShort(),i=c.parseUShort(),j=g;h>=j;j++)f[i++]=j;return f}}function f(a,b){var c=new k.Parser(a,b),d=c.parseUShort();if(1===d){var e=c.parseUShort(),f=c.parseUShort(),g=c.parseUShortList(f);return function(a){return g[a-e]||0}}if(2===d){for(var h=c.parseUShort(),i=[],j=[],l=[],m=0;h>m;m++)i[m]=c.parseUShort(),j[m]=c.parseUShort(),l[m]=c.parseUShort();return function(a){for(var b=0,c=i.length-1;c>b;){var d=b+c+1>>1;ar;r++){var s=q[r],t=n[s];if(!t){t={},g.relativeOffset=s;for(var u=g.parseUShort();u--;){var v=g.parseUShort();l&&(c=g.parseShort()),m&&(d=g.parseShort()),t[v]=c}}p[j[r]]=t}return function(a,b){var c=p[a];return c?c[b]:void 0}}if(2===h){for(var w=g.parseUShort(),x=g.parseUShort(),y=g.parseUShort(),z=g.parseUShort(),A=f(a,b+w),B=f(a,b+x),C=[],D=0;y>D;D++)for(var E=C[D]=[],F=0;z>F;F++)l&&(c=g.parseShort()),m&&(d=g.parseShort()),E[F]=c;var G={};for(D=0;Dm;m++)l.push(g(a,b+i[m]));j.getKerningValue=function(a,b){for(var c=l.length;c--;){var d=l[c](a,b);if(void 0!==d)return d}return 0}}return j}function i(a,b,c){var e=new k.Parser(a,b),f=e.parseFixed();j.argument(1===f,"Unsupported GPOS table version."),d(a,b+e.parseUShort()),d(a,b+e.parseUShort());var g=e.parseUShort();e.relativeOffset=g;for(var i=e.parseUShort(),l=e.parseOffset16List(i),m=b+g,n=0;i>n;n++){var o=h(a,m+l[n]);2!==o.lookupType||c.getGposKerningValue||(c.getGposKerningValue=o.getKerningValue)}}var j=a("../check"),k=a("../parse");c.parse=i},{"../check":1,"../parse":7}],14:[function(a,b,c){"use strict";function d(a,b){var c={},d=new g.Parser(a,b);return c.version=d.parseVersion(),c.fontRevision=Math.round(1e3*d.parseFixed())/1e3,c.checkSumAdjustment=d.parseULong(),c.magicNumber=d.parseULong(),f.argument(1594834165===c.magicNumber,"Font header has wrong magic number."),c.flags=d.parseUShort(),c.unitsPerEm=d.parseUShort(),c.created=d.parseLongDateTime(),c.modified=d.parseLongDateTime(),c.xMin=d.parseShort(),c.yMin=d.parseShort(),c.xMax=d.parseShort(),c.yMax=d.parseShort(),c.macStyle=d.parseUShort(),c.lowestRecPPEM=d.parseUShort(),c.fontDirectionHint=d.parseShort(),c.indexToLocFormat=d.parseShort(),c.glyphDataFormat=d.parseShort(),c}function e(a){return new h.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:0},{name:"modified",type:"LONGDATETIME",value:0},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],a)}var f=a("../check"),g=a("../parse"),h=a("../table");c.parse=d,c.make=e},{"../check":1,"../parse":7,"../table":9}],15:[function(a,b,c){"use strict";function d(a,b){var c={},d=new f.Parser(a,b);return c.version=d.parseVersion(),c.ascender=d.parseShort(),c.descender=d.parseShort(),c.lineGap=d.parseShort(),c.advanceWidthMax=d.parseUShort(),c.minLeftSideBearing=d.parseShort(),c.minRightSideBearing=d.parseShort(),c.xMaxExtent=d.parseShort(),c.caretSlopeRise=d.parseShort(),c.caretSlopeRun=d.parseShort(),c.caretOffset=d.parseShort(),d.relativeOffset+=8,c.metricDataFormat=d.parseShort(),c.numberOfHMetrics=d.parseUShort(),c}function e(a){return new g.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],a)}var f=a("../parse"),g=a("../table");c.parse=d,c.make=e},{"../parse":7,"../table":9}],16:[function(a,b,c){"use strict";function d(a,b,c,d,e){for(var g,h,i=new f.Parser(a,b),j=0;d>j;j+=1){c>j&&(g=i.parseUShort(),h=i.parseShort());var k=e[j];k.advanceWidth=g,k.leftSideBearing=h}}function e(a){for(var b=new g.Table("hmtx",[]),c=0;cj;j+=1){var k=d.parseUShort(),l=d.parseUShort(),m=d.parseShort();c[k+","+l]=m}return c}var e=a("../check"),f=a("../parse");c.parse=d},{"../check":1,"../parse":7}],18:[function(a,b,c){"use strict";function d(a,b,c,d){for(var f=new e.Parser(a,b),g=d?f.parseUShort:f.parseULong,h=[],i=0;c+1>i;i+=1){var j=g.call(f);d&&(j*=2),h.push(j)}return h}var e=a("../parse");c.parse=d},{"../parse":7}],19:[function(a,b,c){"use strict";function d(a,b){var c={},d=new f.Parser(a,b);return c.version=d.parseVersion(),c.numGlyphs=d.parseUShort(),1===c.version&&(c.maxPoints=d.parseUShort(),c.maxContours=d.parseUShort(),c.maxCompositePoints=d.parseUShort(),c.maxCompositeContours=d.parseUShort(),c.maxZones=d.parseUShort(),c.maxTwilightPoints=d.parseUShort(),c.maxStorage=d.parseUShort(),c.maxFunctionDefs=d.parseUShort(),c.maxInstructionDefs=d.parseUShort(),c.maxStackElements=d.parseUShort(),c.maxSizeOfInstructions=d.parseUShort(),c.maxComponentElements=d.parseUShort(),c.maxComponentDepth=d.parseUShort()),c}function e(a){return new g.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:a}])}var f=a("../parse"),g=a("../table");c.parse=d,c.make=e},{"../parse":7,"../table":9}],20:[function(a,b,c){"use strict";function d(a,b){var c={},d=new j.Parser(a,b);c.format=d.parseUShort();for(var e=d.parseUShort(),f=d.offset+d.parseUShort(),g=0,h=0;e>h;h++){var i=d.parseUShort(),k=d.parseUShort(),m=d.parseUShort(),n=d.parseUShort(),o=l[n],p=d.parseUShort(),q=d.parseUShort();if(3===i&&1===k&&1033===m){for(var r=[],s=p/2,t=0;s>t;t++,q+=2)r[t]=j.getShort(a,f+q);var u=String.fromCharCode.apply(null,r);o?c[o]=u:(g++,c["unknown"+g]=u)}}return 1===c.format&&(c.langTagCount=d.parseUShort()),c}function e(a,b,c,d,e,f){return new k.Table("NameRecord",[{name:"platformID",type:"USHORT",value:a},{name:"encodingID",type:"USHORT",value:b},{name:"languageID",type:"USHORT",value:c},{name:"nameID",type:"USHORT",value:d},{name:"length",type:"USHORT",value:e},{name:"offset",type:"USHORT",value:f}])}function f(a,b,c,d){var f=i.STRING(c);return a.records.push(e(1,0,0,b,f.length,d)),a.strings.push(f),d+=f.length}function g(a,b,c,d){var f=i.UTF16(c);return a.records.push(e(3,1,1033,b,f.length,d)),a.strings.push(f),d+=f.length}function h(a){var b=new k.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:0},{name:"stringOffset",type:"USHORT",value:0}]);b.records=[],b.strings=[];var c,d,e=0;for(c=0;c=c.begin&&ae;e++)c.panose[e]=d.parseByte();return c.ulUnicodeRange1=d.parseULong(),c.ulUnicodeRange2=d.parseULong(),c.ulUnicodeRange3=d.parseULong(),c.ulUnicodeRange4=d.parseULong(),c.achVendID=String.fromCharCode(d.parseByte(),d.parseByte(),d.parseByte(),d.parseByte()),c.fsSelection=d.parseUShort(),c.usFirstCharIndex=d.parseUShort(),c.usLastCharIndex=d.parseUShort(),c.sTypoAscender=d.parseShort(),c.sTypoDescender=d.parseShort(),c.sTypoLineGap=d.parseShort(),c.usWinAscent=d.parseUShort(),c.usWinDescent=d.parseUShort(),c.version>=1&&(c.ulCodePageRange1=d.parseULong(),c.ulCodePageRange2=d.parseULong()),c.version>=2&&(c.sxHeight=d.parseShort(),c.sCapHeight=d.parseShort(),c.usDefaultChar=d.parseUShort(),c.usBreakChar=d.parseUShort(),c.usMaxContent=d.parseUShort()),c}function f(a){return new h.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],a)}var g=a("../parse"),h=a("../table"),i=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];c.unicodeRanges=i,c.getUnicodeRange=d,c.parse=e,c.make=f},{"../parse":7,"../table":9}],22:[function(a,b,c){"use strict";function d(a,b){var c,d={},e=new g.Parser(a,b);switch(d.version=e.parseVersion(),d.italicAngle=e.parseFixed(),d.underlinePosition=e.parseShort(),d.underlineThickness=e.parseShort(),d.isFixedPitch=e.parseULong(),d.minMemType42=e.parseULong(),d.maxMemType42=e.parseULong(),d.minMemType1=e.parseULong(),d.maxMemType1=e.parseULong(),d.version){case 1:d.names=f.standardNames.slice();break;case 2:for(d.numberOfGlyphs=e.parseUShort(),d.glyphNameIndex=new Array(d.numberOfGlyphs),c=0;c=f.standardNames.length){var h=e.parseChar();d.names.push(e.parseString(h))}break;case 2.5:for(d.numberOfGlyphs=e.parseUShort(),d.offset=new Array(d.numberOfGlyphs),c=0;cb.value.tag?1:-1}),b.fields=b.fields.concat(g),b.fields=b.fields.concat(h),b}function h(a,b,c){for(var d=0;d0){var f=a.glyphs[e];return f.getMetrics()}}return c}function i(a){for(var b=0,c=0;cD||null===v)&&(v=D),D>w&&(w=D);var E=t.getUnicodeRange(D);if(32>E)x|=1<E)y|=1<E)z|=1<E))throw new Error("Unicode ranges bits > 123 are reserved for internal usage");A|=1<=0&&255>=a,"Byte value should be between 0 and 255."),[a]},j.BYTE=d(1),i.CHAR=function(a){return[a.charCodeAt(0)]},j.BYTE=d(1),i.CHARARRAY=function(a){for(var b=[],c=0;c>8&255,255&a]},j.USHORT=d(2),i.SHORT=function(a){return a>=f&&(a=-(2*f-a)),[a>>8&255,255&a]},j.SHORT=d(2),i.UINT24=function(a){return[a>>16&255,a>>8&255,255&a]},j.UINT24=d(3),i.ULONG=function(a){return[a>>24&255,a>>16&255,a>>8&255,255&a]},j.ULONG=d(4),i.LONG=function(a){return a>=g&&(a=-(2*g-a)),[a>>24&255,a>>16&255,a>>8&255,255&a]},j.LONG=d(4),i.FIXED=i.ULONG,j.FIXED=j.ULONG,i.FWORD=i.SHORT,j.FWORD=j.SHORT,i.UFWORD=i.USHORT,j.UFWORD=j.USHORT,i.LONGDATETIME=function(){return[0,0,0,0,0,0,0,0]},j.LONGDATETIME=d(8),i.TAG=function(a){return e.argument(4===a.length,"Tag should be exactly 4 ASCII characters."),[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)]},j.TAG=d(4),i.Card8=i.BYTE,j.Card8=j.BYTE,i.Card16=i.USHORT,j.Card16=j.USHORT,i.OffSize=i.BYTE,j.OffSize=j.BYTE,i.SID=i.USHORT,j.SID=j.USHORT,i.NUMBER=function(a){return a>=-107&&107>=a?[a+139]:a>=108&&1131>=a?(a-=108,[(a>>8)+247,255&a]):a>=-1131&&-108>=a?(a=-a-108,[(a>>8)+251,255&a]):a>=-32768&&32767>=a?i.NUMBER16(a):i.NUMBER32(a)},j.NUMBER=function(a){return i.NUMBER(a).length},i.NUMBER16=function(a){return[28,a>>8&255,255&a]},j.NUMBER16=d(2),i.NUMBER32=function(a){return[29,a>>24&255,a>>16&255,a>>8&255,255&a]},j.NUMBER32=d(4),i.NAME=i.CHARARRAY,j.NAME=j.CHARARRAY,i.STRING=i.CHARARRAY,j.STRING=j.CHARARRAY,i.UTF16=function(a){for(var b=[],c=0;ce;e+=1){var f=parseInt(c[e],0),g=a[f];b=b.concat(i.OPERAND(g.value,g.type)),b=b.concat(i.OPERATOR(f))}return b},j.DICT=function(a){return i.DICT(a).length},i.OPERATOR=function(a){return 1200>a?[a]:[12,a-1200]},i.OPERAND=function(a,b){var c=[];if(Array.isArray(b))for(var d=0;dd;d+=1){var e=a[d];b=b.concat(i[e.type](e.value))}return k&&k.set(a,b),b},j.CHARSTRING=function(a){return i.CHARSTRING(a).length},i.OBJECT=function(a){var b=i[a.type];return e.argument(void 0!==b,"No encoding function for type "+a.type),b(a.value)},i.TABLE=function(a){for(var b=[],c=a.fields.length,d=0;c>d;d+=1){var f=a.fields[d],g=i[f.type];e.argument(void 0!==g,"No encoding function for field type "+f.type);var h=a[f.name];void 0===h&&(h=f.value);var j=g(h);b=b.concat(j)}return b},i.LITERAL=function(a){return a},j.LITERAL=function(a){return a.length},c.decode=h,c.encode=i,c.sizeOf=j},{"./check":1}]},{},[6])(6)});p5.prototype._validateParameters = function() {};p5.prototype._friendlyFileLoadError = function() {}; \ No newline at end of file