Type + Code: Processing For Designers

Page 61

Type + Code page >R< odd page {37} >Pattern Generation<

14.0

Pattern Design

import processing.pdf.*; PFont myFont; void setup() { size(800, 800); beginRecord(PDF, "pattern.pdf"); background(255,255,255);

Using hierarchy, color, rotation and other components of graphic design, pattern design requires a repetition of elements. Whether we apply them manually or use mathematical formulas, we need to use a multiple. In this example, we are using three for() functions, therefore, we need more variables: i, j and k. The for() statements are for(int i=0;i<800;i=i+200), for(int j=0;j<800;j=j+200), and for(int k=0;k<6;k=k+1). Transparency is added by fill(0,0,0,150), with a value of 150. Finally, within the pushMatrix() and popMatrix() statements, textAlign(), rotate(), and text() have been added.

translate(400,400); myFont = createFont("Bodoni",48); textFont(myFont,290); for(int i=0;i<800;i=i+200){

PFont myFont;

for(int j=0;j<800;j=j+200){

void setup(){

for(int k=0;k<6;k=k+1){

size(800, 800);

fill(0,0,0,150); pushMatrix(); textAlign(CENTER); rotate(PI*k/3); text("I", i, j); popMatrix(); } } } endRecord(); }

for(int i=0;i<800;i=i+200){ for(int j=0;j<800;j=j+200){ for(int k=0;k<6;k=k+1){

background(255,255,255); fill(0,0,0,150); translate(400,400);

pushMatrix();

myFont =

textAlign(CENTER);

createFont("Bodoni",48); textFont(myFont,290);

rotate(PI*k/3); text("I", i, j); popMatrix(); } } } }

The above version of the code adds: import processing.pdf.*, beginRecord(PDF, "pattern.pdf") and endRecord() to save the output as “pattern.pdf,” which can then be imported into a vector-based design application such as Adobe Illustrator where color and transparency can be added.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.