• Shyam Patel

Book Brief - Coding Workshop 3

In this section of the workshop, it was all about using the skills and knowledge of code from previous workshops and putting it together. This, however, added the new element of typography. In this part of the workshop, we put together lines of poetry to coincide with the crazy papercut geometric glitched lines and shapes. The outcomes at the bottom of the page were the results of modifying and experimenting with the code.

//-----------------------------------------------------------------

//Random book generation for AOL User Data - 23187425

//A poem

//Rob Lycett - February 24th, 2013

//Based upon RandomBook.pde

//-----------------------------------------------------------------

import processing.pdf.*;

PGraphicsPDF pdf;

int n = 25;//number of pages

PFont poemFont;

String[] poem;

String poemString;

void setup() {

size(612, 859);//lulu A4 with bleed

//setup fonts

poemFont = createFont("Bodoni 72 Smallcaps Book.ttf", 72); // creates the selected font from the datelibrary

//load data

poem = loadStrings("aol_user_23187425.txt"); // loads the text from the .txt file

//first line of txt file is poem title // lets the code know that the first line of the poem is in fact the title, not the poem itself.

poemString = poem[0];

//setup pdf parameters

pdf = (PGraphicsPDF)beginRecord(PDF, "book_AOL23187425_A4bleed1.pdf");

beginRecord(pdf);

}

void draw() { //

background(249);

for (int i=0; i<250; i++) {

float r = random(1.0);

if (r < 0.4) {

stroke(random (125),random (165), random (155)) ; // this line of code is activated and allows for the colours to be changed.

fill(random (235),random (125), random (195)); // this line of code is activated and allows for the colours to be changed.

// stroke(random (125,219)) ; // This line of code has been used as a comment which can easily be replaced as an active line of code, therefore, applying transparency

// fill(random (235,157)); // This line of code has been used as a comment which can easily be replaced as an active line of code, therefore, applying transparency

} else {

// stroke(random (211,231)); // This line of code has been used as a comment which can easily be replaced as an active line of code, therefore, applying transparency

fill(random (220), random (125), random (159)); // this line of code is activated and allows for the colours to be changed.

// The comments that can be activated as an active line of code are there if I want to change the colours of the outcomes.

}

float sw = pow(random(1.0), 12);

strokeWeight(sw * 250);

float x1 = random(-200, -100);

float x2 = random(width+100, width+200);

float y1 = random(-100, height+100);

float y2 = random(-100, height+100);

line(x1, y1, x2, y2);

// random line of txt

poemString = poem[floor(random(poem.length))]; // the poem string is randomly chosen from the poem array

textFont(poemFont);

//fill(0);

textAlign(CENTER);

text(poemString, random(width+100, width+200), random(-100, height+100));

}

if (frameCount == n) {

endRecord();

exit(); // Quit

} else {

pdf.nextPage(); // Tell it to go to the next page

}




13 views
Social Media Logo.png