diff --git a/quin_kennedy/recode_v1n4_Generative_Drawings_by_Manfred_Mohr/recode_v1n4_Generative_Drawings_by_Manfred_Mohr.pde b/quin_kennedy/recode_v1n4_Generative_Drawings_by_Manfred_Mohr/recode_v1n4_Generative_Drawings_by_Manfred_Mohr.pde new file mode 100644 index 0000000..bfab96e --- /dev/null +++ b/quin_kennedy/recode_v1n4_Generative_Drawings_by_Manfred_Mohr/recode_v1n4_Generative_Drawings_by_Manfred_Mohr.pde @@ -0,0 +1,228 @@ +// This sketch is part of the ReCode Project - http://recodeproject.com +// From Computer Graphics and Art vol1 no4 pg 6 +// Generative Drawings +// by Manfred Mohr +// +// Quin Kennedy +// 2012 +// Creative Commons license CC BY-SA 3.0 +static final int cellWidth = 30; +static final int boxSize = 7; +static int numEdges = 9; +static final int cubeEdges = 12; +static final int numUnique = factorial(cubeEdges)/(factorial(numEdges)*factorial(cubeEdges-numEdges)); +static final int numCellsWide = ceil(sqrt(numUnique)); +static final int gutterWidth = 10; +static final int canvasWidth = numCellsWide*cellWidth+gutterWidth*2; +static final boolean showMirror = true; +static final boolean closerMatch = true; + +public static final int factorial(int n){ + int output = 1; + for(;n>0; n--){ + output *= n; + } + return output; +} + +void setup(){ + size(canvasWidth * (showMirror ? 2 : 1), canvasWidth, P3D); + noLoop(); +} + +void draw(){ + background(0); + noFill(); + stroke(255); + strokeWeight(1.5); + ortho(); + drawGrid(); + drawSet(); + if (showMirror){ + translate(width/2, 0, 0); + drawGrid(); + numEdges = cubeEdges-numEdges; + drawSet(); + } +} + +void drawSet(){ + pushMatrix(); + int currCubeEdges = (closerMatch ? initCubeFlags() : 0); + float rX = PI/3;//random(TWO_PI); + float rY = 0;//random(TWO_PI); + float rZ = PI*2/3;//random(TWO_PI); + translate(gutterWidth+cellWidth/2., numCellsWide*cellWidth+gutterWidth-cellWidth/2., 0); + for(int i = 0; i < numCellsWide; i++){ + pushMatrix(); + for(int j = 0; j < numCellsWide; j++){ + pushMatrix(); + rotateX(rX); + rotateY(rY); + rotateZ(rZ); + scale(boxSize); + if (closerMatch){ + drawCube(currCubeEdges); + currCubeEdges = getNextCube(currCubeEdges); + } else { + for(;currCubeEdges <= 0xfff; currCubeEdges++){ + if (numFlags(currCubeEdges) == numEdges){ + drawCube(currCubeEdges); + currCubeEdges++; + break; + } + } + } + popMatrix(); + translate(0, -cellWidth, 0); + } + popMatrix(); + translate(cellWidth, 0, 0); + } + popMatrix(); +} + +int numFlags(int f){ + int output = 0; + while(f > 0){ + if ((f & 1) == 1){ + output++; + } + f >>= 1; + } + return output; +} + +void drawGrid(){ + int currX = gutterWidth; + for(int i = 0; i <= numCellsWide; i++, currX += cellWidth){ + line(currX, gutterWidth, currX, numCellsWide*cellWidth+gutterWidth); + line(gutterWidth, currX, numCellsWide*cellWidth+gutterWidth, currX); + } +} + +int initCubeFlags(){ + int firstFlags = 0; + for(int i = 0; i < numEdges; i++){ + firstFlags <<= 1; + firstFlags++; + } + return firstFlags; +} + +int getNextCube(int sideFlags){ + return incrementFlags(sideFlags, cubeEdges-1); +} + +int incrementFlags(int sideFlags, int lastValidIndex){ + int myMask = 1; + int bitMask = 1; + for(int i = 1; i <= lastValidIndex; i++){ + bitMask <<= 1; + myMask <<= 1; + myMask++; + } + if ((sideFlags & bitMask) > 1){ + //if there are no flags below us, we are done, return 0; + if ((sideFlags & (myMask >> 1)) == 0){ + return 0; + } + //move the flags below us + int nextFlags = incrementFlags(sideFlags, lastValidIndex-1); + //if we receive 0, we are done with the whole series + if (nextFlags == 0){ + return 0; + } + //otherwise reset our flag to directly after theirs + while(bitMask > 0 && (nextFlags & (bitMask >> 1)) == 0){ + bitMask >>= 1; + } + return (nextFlags | bitMask); + } else { + //move this flag up by one position + //find where the flag is + while(bitMask > 0 && (sideFlags & (bitMask >> 1)) == 0){ + bitMask >>= 1; + } + //mask my section, remove the current flag and add the new flag + return (((sideFlags & myMask) ^ (bitMask >> 1)) | bitMask); + } +} + +void drawCube(int sideFlags){ + if (closerMatch){ + if ((sideFlags & 0x1) != 0){ + line(1, -1, -1, 1, 1, -1); + } + if ((sideFlags & 0x2) != 0){ + line(1, 1, 1, 1, -1, 1); + } + if ((sideFlags & 0x4) != 0){ + line(-1, -1, 1, -1, 1, 1); + } + if ((sideFlags & 0x8) != 0){ + line(-1, -1, -1, 1, -1, -1); + } + if ((sideFlags & 0x10) != 0){ + line(1, -1, -1, 1, -1, 1); + } + if ((sideFlags & 0x20) != 0){ + line(-1, -1, 1, 1, -1, 1); + } + if ((sideFlags & 0x40) != 0){ + line(-1, -1, -1, -1, -1, 1); + } + if ((sideFlags & 0x80) != 0){ + line(-1, -1, -1, -1, 1, -1); + } + if ((sideFlags & 0x100) != 0){ + line(-1, 1, -1, 1, 1, -1); + } + if ((sideFlags & 0x200) != 0){ + line(1, 1, 1, 1, 1, -1); + } + if ((sideFlags & 0x400) != 0){ + line(1, 1, 1, -1, 1, 1); + } + if ((sideFlags & 0x800) != 0){ + line(-1, 1, -1, -1, 1, 1); + } + } else { + if ((sideFlags & 0x1) != 0){ + line(-1, -1, -1, -1, -1, 1); + } + if ((sideFlags & 0x2) != 0){ + line(-1, -1, -1, -1, 1, -1); + } + if ((sideFlags & 0x4) != 0){ + line(-1, -1, -1, 1, -1, -1); + } + if ((sideFlags & 0x8) != 0){ + line(1, 1, 1, 1, 1, -1); + } + if ((sideFlags & 0x10) != 0){ + line(1, 1, 1, 1, -1, 1); + } + if ((sideFlags & 0x20) != 0){ + line(1, 1, 1, -1, 1, 1); + } + if ((sideFlags & 0x40) != 0){ + line(-1, -1, 1, 1, -1, 1); + } + if ((sideFlags & 0x80) != 0){ + line(-1, -1, 1, -1, 1, 1); + } + if ((sideFlags & 0x100) != 0){ + line(-1, 1, -1, 1, 1, -1); + } + if ((sideFlags & 0x200) != 0){ + line(-1, 1, -1, -1, 1, 1); + } + if ((sideFlags & 0x400) != 0){ + line(1, -1, -1, 1, 1, -1); + } + if ((sideFlags & 0x800) != 0){ + line(1, -1, -1, 1, -1, 1); + } + } +} diff --git a/quin_kennedy/recode_v3n1_P196A_by_Manfred_Mohr/recode_v3n1_P196A_by_Manfred_Mohr.pde b/quin_kennedy/recode_v3n1_P196A_by_Manfred_Mohr/recode_v3n1_P196A_by_Manfred_Mohr.pde new file mode 100644 index 0000000..5600436 --- /dev/null +++ b/quin_kennedy/recode_v3n1_P196A_by_Manfred_Mohr/recode_v3n1_P196A_by_Manfred_Mohr.pde @@ -0,0 +1,59 @@ +// This sketch is part of the ReCode Project - http://recodeproject.com +// From Computer Graphics and Art vol3 no1 pg 9 +// P-196A +// by Manfred Mohr +// +// Quin Kennedy +// 2012 +// Creative Commons license CC BY-SA 3.0 +static final int boxSize = 300; +static final int canvasSize = 600; + +void setup(){ + size(canvasSize, canvasSize, P2D); + noLoop(); +} + +void draw(){ +translate(width/2, height/2, 0); +PGraphics topLight = createGraphics(width, height, P3D); +PGraphics bottomLight = createGraphics(width, height, P3D); +PGraphics topHeavy = createGraphics(width, height, P3D); +PGraphics bottomHeavy = createGraphics(width, height, P3D); +float rX = random(TWO_PI); +float rY = random(TWO_PI); +float rZ = random(TWO_PI); +drawBox(topLight, rX, rY, rZ, 1, 255); +drawBox(topHeavy, rX, rY, rZ, 4, 252); +rX = random(TWO_PI); +rY = random(TWO_PI); +rZ = random(TWO_PI); +drawBox(bottomLight, rX, rY, rZ, 1, 255); +drawBox(bottomHeavy, rX, rY, rZ, 4, 252); + +copy(topLight, 0, 0, width, height/2, 0, 0, width, height/2); +copy(bottomLight, 0, height/2, width, height/2, 0, height/2, width, height/2); +int pX = (width-boxSize)/2; +int pY = (height-boxSize)/2; +int cW = boxSize; +int cH = boxSize/2; +copy(topHeavy, pX, pY, cW, cH, pX, pY, cW, cH); +pY += boxSize/2; +copy(bottomHeavy, pX, pY, cW, cH, pX, pY, cW, cH); +line(0, height/2, width, height/2); +} + +void drawBox(PGraphics g, float rotX, float rotY, float rotZ, float weight, int backgroundColor){ + g.beginDraw(); + g.ortho(); + g.translate(width/2, height/2, 0); + g.rotateX(rotX); + g.rotateY(rotY); + g.rotateZ(rotZ); + g.background(backgroundColor); + g.stroke(0); + g.strokeWeight(weight); + g.noFill(); + g.box(boxSize); + g.endDraw(); +} diff --git a/quin_kennedy/recode_v3n1_P197A_by_Manfred_Mohr/recode_v3n1_P197A_by_Manfred_Mohr.pde b/quin_kennedy/recode_v3n1_P197A_by_Manfred_Mohr/recode_v3n1_P197A_by_Manfred_Mohr.pde new file mode 100644 index 0000000..931bc2b --- /dev/null +++ b/quin_kennedy/recode_v3n1_P197A_by_Manfred_Mohr/recode_v3n1_P197A_by_Manfred_Mohr.pde @@ -0,0 +1,117 @@ +// This sketch is part of the ReCode Project - http://recodeproject.com +// From Computer Graphics and Art vol3 no1 pg 6 +// P-197A +// by Manfred Mohr +// +// Quin Kennedy +// 2012 +// Creative Commons license CC BY-SA 3.0 +static final int idealCanvasSize = 600; +static final int numCellsWide = 8; +static final int boxSize = 300/(numCellsWide+2)/2*2;//we want it to be even +static final float gutterRatio = 1; +static final int cellWidth = ((int)(idealCanvasSize/(numCellsWide+gutterRatio*2)))/2*2;//we want an even number +static final int gutterWidth = (int)(cellWidth*gutterRatio); +static final int actualCanvasSize = cellWidth*numCellsWide+gutterWidth*2; +static final float gutterBleed = .5; + +void setup(){ + size(actualCanvasSize, actualCanvasSize, P3D); + noLoop(); +} + +void draw(){ + drawV1(); +} + +void drawV1(){ + background(255); + PGraphics topLight = createGraphics(cellWidth, cellWidth, P3D); + PGraphics bottomLight = createGraphics(cellWidth, cellWidth, P3D); + PGraphics topHeavy = createGraphics(cellWidth, cellWidth, P3D); + PGraphics bottomHeavy = createGraphics(cellWidth, cellWidth, P3D); + + int halfCellWidth = cellWidth/2; + int currOffsetX = gutterWidth; + int currOffsetY; + for(int i = 0; i < numCellsWide; i++, currOffsetX += cellWidth){ + currOffsetY = gutterWidth; + for(int j = 0; j < numCellsWide; j++, currOffsetY += cellWidth){ + //render the source material + float rX = random(TWO_PI); + float rY = random(TWO_PI); + float rZ = random(TWO_PI); + drawBox(topLight, rX, rY, rZ, .8, 255); + drawBox(topHeavy, rX, rY, rZ, 2, 255);//252); + rX = random(TWO_PI); + rY = random(TWO_PI); + rZ = random(TWO_PI); + drawBox(bottomLight, rX, rY, rZ, .8, 255); + drawBox(bottomHeavy, rX, rY, rZ, 2, 255);//252); + + //draw as appropriate, + //this would be better to do with viewports and scissor oporations, + //but I can't figure out how to do that in Processing + copy(topLight, 0, 0, halfCellWidth, cellWidth, currOffsetX, currOffsetY, halfCellWidth, cellWidth); + copy(bottomLight, halfCellWidth, 0, halfCellWidth, cellWidth, currOffsetX + halfCellWidth, currOffsetY, halfCellWidth, cellWidth); + int pX = (cellWidth-boxSize)/2; + int pY = (cellWidth-boxSize)/2; + int cW = boxSize/2; + int cH = boxSize; + copy(topHeavy, pX, pY, cW, cH, currOffsetX+pX, currOffsetY+pY, cW, cH); + pX += boxSize/2; + copy(bottomHeavy, pX, pY, cW, cH, currOffsetX+pX, currOffsetY+pY, cW, cH); + } + } +} + +void drawBox(PGraphics g, float rotX, float rotY, float rotZ, float weight, int backgroundColor){ + g.beginDraw(); + g.ortho(); + g.background(backgroundColor); + + //draw horizontal line + g.stroke(0); + g.strokeWeight(1); + g.line(0, g.height/2, -boxSize*3, g.width, g.height/2, -boxSize*3); + + //cover the horizontal line + g.pushMatrix(); + g.translate(g.width/2, g.height/2, -boxSize*2); + g.rotateX(rotX); + g.rotateY(rotY); + g.rotateZ(rotZ); + g.noStroke(); + g.fill(backgroundColor); + g.box(boxSize); + g.popMatrix(); + + //now draw the cube outline + g.pushMatrix(); + g.translate(g.width/2, g.height/2, 0); + g.rotateX(rotX); + g.rotateY(rotY); + g.rotateZ(rotZ); + g.stroke(0); + g.strokeWeight(weight); + g.noFill(); + g.box(boxSize); + g.popMatrix(); + + //draw vertical line + g.strokeWeight(1); + g.line(g.width/2, 0, boxSize, g.width/2, g.height, boxSize); + g.endDraw(); +} + +void drawGrid(boolean bHorizontal){ + int currOffset = gutterWidth+cellWidth/2; + int visualGutter = gutterWidth-((int)(gutterWidth*gutterBleed)); + for(int i = 0; i < numCellsWide; i++, currOffset += cellWidth){ + if (bHorizontal){ + line(visualGutter, currOffset, -boxSize*3, width-visualGutter, currOffset, -boxSize*3); + } else { + line(currOffset, visualGutter, boxSize, currOffset, height-visualGutter, boxSize); + } + } +} diff --git a/quin_kennedy/recode_v3n1_P211A_by_Manfred_Mohr/http---www.emohr.com-mohr_cube1_211.html (20121216).png b/quin_kennedy/recode_v3n1_P211A_by_Manfred_Mohr/http---www.emohr.com-mohr_cube1_211.html (20121216).png new file mode 100644 index 0000000..32660a6 Binary files /dev/null and b/quin_kennedy/recode_v3n1_P211A_by_Manfred_Mohr/http---www.emohr.com-mohr_cube1_211.html (20121216).png differ diff --git a/quin_kennedy/recode_v3n1_P211A_by_Manfred_Mohr/recode_v3n1_P211A_by_Manfred_Mohr.pde b/quin_kennedy/recode_v3n1_P211A_by_Manfred_Mohr/recode_v3n1_P211A_by_Manfred_Mohr.pde new file mode 100644 index 0000000..e679a9c --- /dev/null +++ b/quin_kennedy/recode_v3n1_P211A_by_Manfred_Mohr/recode_v3n1_P211A_by_Manfred_Mohr.pde @@ -0,0 +1,158 @@ +// This sketch is part of the ReCode Project - http://recodeproject.com +// From Computer Graphics and Art vol3 no1 pg 7 +// P-211A +// by Manfred Mohr +// +//extra inspiration from: http://www.emohr.com/mohr_cube1_211.html +// - screenshot included in repo +// +// Quin Kennedy +// 2012 +// Creative Commons license CC BY-SA 3.0 +static final int boxSize = 80; +static final int cellSize = 190; +static final int numCells = 7; +static final int gutter = 10; +static final int canvasWidth = cellSize*numCells+gutter*(numCells+1); +static final int canvasHeight = cellSize+gutter*2; +int[] edgePairs = {0, 1, + 2, 3, + 1, 3, + 0, 2, + + 4, 5, + 6, 7, + 5, 7, + 4, 6, + + 0, 4, + 1, 5, + 2, 6, + 3, 7}; +PVector[] endpoints = new PVector[edgePairs.length]; + +void setup(){ + size(canvasWidth, canvasHeight, P3D); + noLoop(); +} + +void draw(){ + smooth(2); + ortho(0, width, 0, height, Float.MIN_VALUE, Float.MAX_VALUE); + strokeJoin(ROUND); + background(255); + + boolean calcExtended = true; + PVector rot = new PVector( + random(TWO_PI), + random(TWO_PI), + random(TWO_PI)); + PVector rotV = new PVector( + random(-QUARTER_PI/4, QUARTER_PI/4), + random(-QUARTER_PI/4, QUARTER_PI/4), + random(-QUARTER_PI/4, QUARTER_PI/4)); + for(int k = 0, minX = gutter, minY = gutter, maxX = gutter+cellSize, maxY = gutter+cellSize; + k < numCells; + k++, minX += gutter+cellSize, maxX += gutter+cellSize){ + if (!calcExtended){ + rot.add(rotV); + for(int i = 0; i < edgePairs.length; i++){ + endpoints[i].x += cellSize + gutter; + } + } + //draw square + drawSquare(minX, minY, maxX, maxY, calcExtended, rot); + calcExtended = !calcExtended; + } +} + +void drawSquare(int minX, int minY, int maxX, int maxY, boolean calcExtended, PVector rot){ + pushMatrix(); + translate((minX+maxX)/2., (minY+maxY)/2., 0); + //calculate extended points + rotateX(rot.x); + rotateY(rot.y); + rotateZ(rot.z); + scale(boxSize); + //background(255); + noFill(); + stroke(0, 0, 0, 50); + strokeWeight(2); + box(1); + PVector[] points = getVertices(); + popMatrix(); + stroke(0); + strokeWeight(2); + for(int i = 0; i < edgePairs.length; i += 2){ + if (calcExtended){ + calcExtendEdge(i, i+1, points, minX, minY, maxX, maxY); + } + extendEdge(i, i+1, points); + } + stroke(200); + strokeWeight(1); + rect(minX, minY, cellSize, cellSize); +} + +PVector[] getVertices(){ + PVector[] points = new PVector[8]; + int c = 0; + for(float i = -.5; i <=.5; i+= 1){ + for(float j = -.5; j <= .5; j+=1){ + for(float k = -.5; k <= .5; k+=1, c++){ + points[c] = new PVector(modelX(i,j,k), modelY(i,j,k), modelZ(i,j,k)); + } + } + } + return points; +} + +void calcExtendEdge(int i1, int i2, PVector[] points, float minX, float minY, float maxX, float maxY){ + PVector p1 = points[edgePairs[i1]]; + PVector p2 = points[edgePairs[i2]]; + PVector pV = PVector.sub(p2, p1); + float nX = (minX-p1.x)/pV.x;//p1.x+n*pV.x = 0 + float nY = (minY-p1.y)/pV.y; + float nX2 = (maxX - p1.x)/pV.x; + float nY2 = (maxY -p1.y)/pV.y; + float n = Integer.MAX_VALUE; + float n2 = Integer.MIN_VALUE; + float[] all = {nX, nY, nX2, nY2}; + for(int j = 0; j < all.length; j++){ + if (all[j] > 0 && all[j] < n){ + n = all[j]; + } else if (all[j] < 0 && all[j] > n2){ + n2 = all[j]; + } + } + PVector pF = PVector.add(p1, PVector.mult(pV, n)); + PVector pF2 = PVector.add(p1, PVector.mult(pV, n2)); + endpoints[i1] = pF2; + endpoints[i2] = pF; + /* + println(i1+","+i2); + println(p1.x+","+p1.y+","+p1.z); + println(p2.x+","+p2.y+","+p2.z); + println(" -> "+pV.x+","+pV.y+","+pV.z); + println(" - "+nX); + println(" - " + nY); + println(" - " + nX2); + println(" - " + nY2); + println(" :: " + n); + println(" --> " + pF.x+","+pF.y+","+pF.z);*/ +} + +void extendEdge(int i1, int i2, PVector[] points){ + PVector p1 = points[edgePairs[i1]]; + PVector p2 = points[edgePairs[i2]]; + PVector pF = endpoints[i2]; + PVector pF2 = endpoints[i1]; + line(p2.x, p2.y, p2.z, pF.x, pF.y, pF.z); + line(p1.x, p1.y, p2.z, pF2.x, pF2.y, pF2.z); + /* + println(i1+","+i2); + println(p1.x+","+p1.y+","+p1.z); + println(p2.x+","+p2.y+","+p2.z); + println(" --> " + pF.x+","+pF.y+","+pF.z); + println(" --> " + pF2.x+","+pF2.y+","+pF2.z);*/ +} diff --git a/quin_kennedy/recode_v3n2_Untitled_1_by_Aaron_Marcus/data/STIXVariants-Bold-15.vlw b/quin_kennedy/recode_v3n2_Untitled_1_by_Aaron_Marcus/data/STIXVariants-Bold-15.vlw new file mode 100644 index 0000000..884a8c3 Binary files /dev/null and b/quin_kennedy/recode_v3n2_Untitled_1_by_Aaron_Marcus/data/STIXVariants-Bold-15.vlw differ diff --git a/quin_kennedy/recode_v3n2_Untitled_1_by_Aaron_Marcus/recode_v3n2_Untitled_1_by_Aaron_Marcus.pde b/quin_kennedy/recode_v3n2_Untitled_1_by_Aaron_Marcus/recode_v3n2_Untitled_1_by_Aaron_Marcus.pde new file mode 100644 index 0000000..398bfda --- /dev/null +++ b/quin_kennedy/recode_v3n2_Untitled_1_by_Aaron_Marcus/recode_v3n2_Untitled_1_by_Aaron_Marcus.pde @@ -0,0 +1,132 @@ +// This sketch is part of the ReCode Project - http://recodeproject.com +// From Computer Graphics and Art vol3 no2 pg 16 +// Untitled 1 +// by Aaron Marcus +// +// Quin Kennedy +// 2012 +// Creative Commons license CC BY-SA 3.0 +char[] carat = Character.toChars(unhex("0302"));//carat +char[] filledSquare = Character.toChars(unhex("25FC"));//Black medium square +char[] emptySquare = Character.toChars(unhex("25FB"));//White medium square + //Character.toChars(unhex("25A2"));//White square with rouded corners +char[] medBar = Character.toChars(unhex("2759"));//medium vertical bar +char[] umlaut = Character.toChars(unhex("0308"));//umlaut +char[] bar = {'|'};//Character.toChars(unhex("2223"));//Character.toChars(unhex("2758"));// +char[] circle = {'O'};//{'o'};// Character.toChars(unhex("25CB"));//25EF"));// +char[] period = {'.'}; +char[] space = {' '}; +Symbol[] symbolSet = {new Symbol(carat, 0, 2./48., true), + new Symbol(umlaut, 2./39., 2./39., true), + new Symbol(circle, 1./39., -1./48., false), + new Symbol(emptySquare, 2./39., -1./39., false), + new Symbol(period, 2./39., -1./39., true), + new Symbol(space, 20./39., 19./48., false), + new Symbol(bar, 20./39., 19./48., false), + new Symbol(medBar, 0, 4./48., false), + new Symbol(filledSquare, 1./200., 9./48., false)}; +Symbol lastSymbol = null; +//number selection inspired by version in PDF, not screenshot on website. +static final int numLines = 32; +static final int maxLinePixelWidth = 250; +static final int minLinePixelWidth = 100; +static final float aspectRatio = 2./3.; +static final int vertBorder = 50; +static final int hBorder = 80; +static final int lineHeight = 15; +PFont f; +boolean wasModifier = false; + +void setup(){ + size(maxLinePixelWidth+hBorder*2, numLines*lineHeight+vertBorder*2); + noLoop(); + f = loadFont("STIXVariants-Bold-15.vlw");//"OriyaSangamMN-15.vlw");//"Raanana-15.vlw");//"LithosPro-Regular-15.vlw");//"OriyaMN-15.vlw");//"KhmerMN-15.vlw""LiHeiPro-15.vlw" "TeluguMN-15.vlw""TeluguMN-Bold-15.vlw""PTSans-Caption-15.vlw""STIXGeneral-Regular-15.vlw" + textFont(f, 15); + normalizeSymbols(); +} + +void normalizeSymbols(){ + float endPSum = 0, startPSum = 0; + for(Symbol s : symbolSet){ + endPSum += s.endP;//max(0, s.endP); + startPSum += s.startP;//max(0, s.startP); + } + for(Symbol s : symbolSet){ + s.endP /= endPSum; + s.startP /= startPSum; + } +} + +void draw(){ + smooth(8); + background(0); + stroke(255);//240);// + fill(255);//240);// + strokeWeight(1); + strokeJoin(SQUARE); + strokeCap(SQUARE); + pushMatrix(); + textAlign(CENTER, TOP); + translate(width/2., vertBorder); + int offset = 0; + for(int i = 0; i < numLines; i++){ + drawLine(((float)i)/numLines); + translate(0, lineHeight); + } + popMatrix(); +} + +void drawLine(float progress){ + int linePixelWidth = floor(random(minLinePixelWidth, maxLinePixelWidth+1)); + String currLine = ""; + String nextChar = ""; + boolean bSuccess = false; + boolean isModifier = false; + while(textWidth(trim(currLine+nextChar)) <= linePixelWidth){ + currLine += nextChar; + nextChar = getNext(progress); + } + text(trim(currLine), 0, 0); +} + +String getNext(float progress){ + Symbol currSymbol; + boolean bSuccess; + do{ + float r = random(1); + int i = -1; + while(r >= 0 && i < symbolSet.length - 1){ + i++; + r -= max(0, symbolSet[i].getCurrP(progress)); + } + currSymbol = symbolSet[i]; + bSuccess = lastSymbol == null || !(lastSymbol.modifier && currSymbol.modifier); + }while(!bSuccess); + lastSymbol = currSymbol; + return new String(currSymbol.unicode); +} + +class Symbol{ + char[] unicode; + float startP; + float endP; + float currP; + boolean modifier; + + public Symbol(char[] _unicode, float _startP, float _endP, boolean _modifier){ + unicode = _unicode; + startP = _startP; + endP = _endP; + currP = _startP; + modifier = _modifier; + } + + float getCurrP(float p){ + progress(p); + return currP; + } + + void progress(float p){ + currP = startP * (1-p) + endP * p; + } +} diff --git a/quin_kennedy/recode_v3n2_Untitled_3_by_Aaron_Marcus/recode_v3n2_Untitled_3_by_Aaron_Marcus.pde b/quin_kennedy/recode_v3n2_Untitled_3_by_Aaron_Marcus/recode_v3n2_Untitled_3_by_Aaron_Marcus.pde new file mode 100644 index 0000000..1dec664 --- /dev/null +++ b/quin_kennedy/recode_v3n2_Untitled_3_by_Aaron_Marcus/recode_v3n2_Untitled_3_by_Aaron_Marcus.pde @@ -0,0 +1,130 @@ +// This sketch is part of the ReCode Project - http://recodeproject.com +// From Computer Graphics and Art vol3 no2 pg 17 +// Untitled 3 (from "Hieroglyphs Series") +// by Aaron Marcus +// +// Quin Kennedy +// 2012 +// Creative Commons license CC BY-SA 3.0 +static final int numLines = 21; +static final int numShapes = 7; +static final int lineHalfHeight = 16; +static final int borderPixelSize = 15; +static final int canvasSize = numLines*2*lineHalfHeight+borderPixelSize*2; +static final float aspectRatio = 670/700.;//taken from reproduction in PDF + +void setup(){ + //the combination of P2D, 1.5 stroke, and no smoothing creates an attractive raw look + size(floor(canvasSize*aspectRatio), canvasSize, P2D); + noLoop(); +} + +void draw(){ + //smooth(8); + background(0); + stroke(255); + noFill(); + strokeWeight(1.5); + strokeJoin(SQUARE); + strokeCap(SQUARE); + pushMatrix(); + translate(borderPixelSize, borderPixelSize + lineHalfHeight); + for(int i = 0; i < numLines; i++){ + drawLine(); + translate(0, lineHalfHeight*2); + } + popMatrix(); +} + +void drawLine(){ + pushMatrix(); + int pixelsRemaining = width-borderPixelSize*2; + int pixelsPrevious = 0; + line(0, 0, pixelsRemaining, 0); + while(pixelsRemaining > 0){ + boolean rightSideUpFirst = random(1) < .5; + int shapeIndex = floor(random(numShapes)); + //small items are more common, quick hack + if(shapeIndex >= 2 && random(1) < .5){ + shapeIndex = floor(random(2)); + } + //large arcs are less common, quick hack + if (shapeIndex == 6 && random(1) < .5){ + shapeIndex = floor(random(numShapes-1)); + } + int pixelsUsed = drawShape(shapeIndex, pixelsRemaining, pixelsPrevious, rightSideUpFirst); + if (shapeIndex < 3){ + shapeIndex = floor(random(3)); + pixelsUsed = max(pixelsUsed, drawShape(shapeIndex, pixelsRemaining, pixelsPrevious, !rightSideUpFirst)); + } + translate(pixelsUsed, 0); + pixelsRemaining -= pixelsUsed; + pixelsPrevious += pixelsUsed; + } + translate(pixelsRemaining, 0); + drawShape(0, defaultStep, pixelsPrevious, true); + popMatrix(); +} + +static final int defaultStep = floor(lineHalfHeight/3); +static final float longDiagWidth = tan(radians(30))*lineHalfHeight; +static final float shortDiagWidth = tan(radians(30))*(lineHalfHeight/2); + + +int drawShape(int i, int pixelsRemaining, int pixelsPrevious, boolean rightSideUp){ + pushMatrix(); + int toReturn = defaultStep; + if (!rightSideUp){ + switch(i){ + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + rotate(PI); + break; + } + } + boolean forward = random(1) < .5; + switch(i){ + case 0://short vertical + line(0, -lineHalfHeight/2., 0, 0); + break; + case 1://short diagonal + if ((forward ? pixelsRemaining : pixelsPrevious) < ceil(shortDiagWidth)){ + toReturn = 0; + break; + } + line(random(1) < .5 ? -shortDiagWidth : shortDiagWidth, -lineHalfHeight/2., 0, 0); + break; + case 2://blank + break; + case 3://long diagonal + if (pixelsRemaining < ceil(longDiagWidth) || pixelsPrevious < ceil(longDiagWidth)){ + toReturn = 0; + break; + } + line(forward ? longDiagWidth : -longDiagWidth, -lineHalfHeight, + forward ? -longDiagWidth : longDiagWidth, lineHalfHeight); + break; + case 4://long vertical + line(0, -lineHalfHeight, 0, lineHalfHeight); + break; + case 5://small circle + ellipse(0, -lineHalfHeight/2., lineHalfHeight/4., lineHalfHeight/4.); + break; + case 6://large arc + if (pixelsRemaining < lineHalfHeight*2){ + toReturn = 0; + break; + } + arc(lineHalfHeight, 0, lineHalfHeight*2, lineHalfHeight*2, + rightSideUp ? PI : 0, + rightSideUp ? TWO_PI : PI); + toReturn = lineHalfHeight*2+defaultStep; + break; + } + popMatrix(); + return toReturn; +}