├── 160506_171123_10575.jpg ├── Deflector.pde ├── Functions.pde ├── Processing_TypeCon.pde └── README.md /160506_171123_10575.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feltron/Processing_TypeCon/60f93be2746a378a3a413a5df4a67365a721fb4e/160506_171123_10575.jpg -------------------------------------------------------------------------------- /Deflector.pde: -------------------------------------------------------------------------------- 1 | 2 | // - - - - - - - - - - - - - - - - - - - - - - - 3 | // DEFLECTOR CLASS 4 | // - - - - - - - - - - - - - - - - - - - - - - - 5 | 6 | class Deflector { 7 | PVector p_location, p_locationPrev, p_velocity, sumAngles; 8 | PVector[] pixelVector = new PVector[9]; 9 | float[] dPath_x; 10 | float[] dPath_y; 11 | boolean flipper = false; 12 | int deflectionType; 13 | 14 | Deflector(PVector mousePosition, int deflectionType_) { 15 | deflectionType = deflectionType_; 16 | initializeDeflector(mousePosition, deflectionType); 17 | } 18 | 19 | // - - - - - - - - - - - - - - - - - - - - - - - 20 | 21 | void display() { 22 | // Draw Rays 23 | beginShape(); 24 | for (int i=1; i 100) { 32 | PVector mousePosition = new PVector(mouseX, mouseY); 33 | myDeflector=(Deflector[])append(myDeflector, new Deflector(mousePosition, deflectionSetting)); 34 | } 35 | } 36 | 37 | // - - - - - - - - - - - - - - - - - - - - - - - 38 | 39 | void mouseDragged() { 40 | PVector mouseClick = new PVector(mouseX, mouseY); 41 | if (mouseY < height-60) { 42 | myDeflector[myDeflector.length-1].initializeDeflector(mouseClick, deflectionSetting); 43 | } 44 | } 45 | 46 | 47 | // - - - - - - - - - - - - - - - - - - - - - - - 48 | 49 | String timestamp() { 50 | Calendar now = Calendar.getInstance(); 51 | return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now); 52 | } 53 | 54 | // - - - - - - - - - - - - - - - - - - - - - - - 55 | 56 | void keyPressed() { 57 | if (key == 's') { 58 | record = true; 59 | } 60 | } 61 | 62 | // - - - - - - - - - - - - - - - - - - - - - - - 63 | 64 | void randomPoint() { 65 | PVector randomLocation = new PVector(random(200, width-200), random(height/2-200, height/2+200)); 66 | myDeflector=(Deflector[])append(myDeflector, new Deflector(randomLocation, deflectionSetting)); 67 | } 68 | 69 | // - - - - - - - - - - - - - - - - - - - - - - - 70 | 71 | void initializeSlider() { 72 | cp5.addSlider("s1") 73 | .setPosition(20, height-30) 74 | .setSize(400, 8) 75 | .setRange(200, 5000) 76 | .setValue(drawCycles) 77 | .setColorForeground(color(255, 128)) 78 | .setColorBackground(color(60)) 79 | .setColorActive(color(255, 128)); 80 | } 81 | 82 | 83 | // - - - - - - - - - - - - - - - - - - - - - - - 84 | 85 | void s1(int sliderValue) { 86 | if (cp5.controller("s1").isMousePressed()) { 87 | drawCycles = sliderValue; 88 | PVector startPosition = new PVector(myDeflector[myDeflector.length-1].dPath_x[0], myDeflector[myDeflector.length-1].dPath_y[0]); 89 | myDeflector[myDeflector.length-1].initializeDeflector(startPosition, deflectionSetting); 90 | } 91 | } 92 | // - - - - - - - - - - - - - - - - - - - - - - - 93 | 94 | void initializeSelector() { 95 | r = cp5.addRadioButton("r1") 96 | .setPosition(20, 20) 97 | .setSize(10, 10) 98 | .setColorForeground(color(255, 128)) 99 | .setColorBackground(color(60)) 100 | .setColorActive(color(255, 200)) 101 | .setColorLabel(color(255)) 102 | .setItemsPerRow(5) 103 | .setSpacingColumn(50) 104 | .addItem("Bounce", 1) 105 | .addItem("Squiggle", 2) 106 | .activate(0); 107 | } 108 | 109 | // - - - - - - - - - - - - - - - - - - - - - - - 110 | 111 | void r1(int a) { 112 | deflectionSetting = a; 113 | PVector startPosition = new PVector(myDeflector[myDeflector.length-1].dPath_x[0], myDeflector[myDeflector.length-1].dPath_y[0]); 114 | myDeflector[myDeflector.length-1].initializeDeflector(startPosition, deflectionSetting); 115 | } 116 | 117 | // - - - - - - - - - - - - - - - - - - - - - - - 118 | 119 | int hexToGrey(int pVal) { 120 | int r=(pVal&0x00FF0000)>>16; 121 | int g=(pVal&0x0000FF00)>>8; 122 | int b=(pVal&0x000000FF); 123 | int grey=(r+b+g)/3; 124 | return grey; 125 | } 126 | 127 | -------------------------------------------------------------------------------- /Processing_TypeCon.pde: -------------------------------------------------------------------------------- 1 | 2 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 | // TypeCon Type Deflector 4 | // by Nicholas Felton 5 | // Reflection-based drawing app developed for TypeCon 2015 Identity System 6 | // Requires Control P5 Library: http://www.sojamo.de/libraries/controlP5/ 7 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | // FEATURES 10 | // Click anywhere to add a new line to drawing. 11 | // Click and hold to change the start position of the last line. 12 | // Subsequent single clicks create new lines. 13 | // Line length and reflection style can be adjusted using the on-screen controls. 14 | // Edit 'typeString' to change text. 15 | // Edit 'typeFace' and 'typeSize' to change the typeface parameters. 16 | // Press 's' key to save drawing as a pdf 17 | 18 | // - - - - - - - - - - - - - - - - - - - - - - - 19 | // LIBRARIES 20 | // - - - - - - - - - - - - - - - - - - - - - - - 21 | import java.util.Calendar; 22 | import processing.pdf.*; 23 | import controlP5.*; 24 | 25 | // - - - - - - - - - - - - - - - - - - - - - - - 26 | // GLOBAL VARIABLES 27 | // - - - - - - - - - - - - - - - - - - - - - - - 28 | 29 | // Type 30 | PFont myFont; 31 | String typeface = "Helvetica-Bold"; 32 | String typeString = "CONDENSED"; 33 | int typeSize = 260; 34 | color c_textFill = color(50); 35 | 36 | // PGraphics 37 | PGraphics pg; 38 | 39 | // Deflector 40 | Deflector myDeflector[]; 41 | int startMarkerSize = 20; 42 | int drawCycles = 1000; 43 | boolean record; 44 | int deflectionFactor = -2; 45 | int deflectionSetting = 1; 46 | 47 | // Control P5 48 | ControlP5 cp5; 49 | Slider s1; 50 | RadioButton r; 51 | 52 | // - - - - - - - - - - - - - - - - - - - - - - - 53 | // SETUP 54 | // - - - - - - - - - - - - - - - - - - - - - - - 55 | void setup() { 56 | size(1800, 600); 57 | smooth(); 58 | cp5 = new ControlP5(this); 59 | initializeSlider(); 60 | initializeSelector(); 61 | myFont = createFont(typeface, 50); 62 | myDeflector = new Deflector[0]; 63 | drawOffScreenText(); // draw buffer once in setup to add initial point 64 | randomPoint(); 65 | } 66 | 67 | // - - - - - - - - - - - - - - - - - - - - - - - 68 | // DRAW 69 | // - - - - - - - - - - - - - - - - - - - - - - - 70 | void draw() { 71 | if (record) { 72 | beginRecord(PDF, timestamp() + "_##.pdf"); 73 | } 74 | background(0); 75 | drawOffScreenText(); 76 | drawScreenText(); 77 | for (int i=0; i