De Casiopea
import processing.pdf.*;
int xNum, yNum, total, counter;
float xSpacer, ySpacer;
String[] code;
PFont courier;
void setup(){
//size(400, 600);
size(1560, 2835);
xNum = 11;
yNum = 23;
total = xNum * yNum;
counter = 0;
xSpacer = width / (float)(xNum + 1);
ySpacer = height / (float)(yNum + 1);
code = loadStrings("lamina.pde");
hint(ENABLE_NATIVE_FONTS);
courier = createFont("Courier", 12);
noLoop();
background(255);
}
void draw(){
beginRecord(PDF, "lamina.pdf");
for (float y = ySpacer; y <= height-ySpacer; y += ySpacer){
float xInit;
if (y > height*0.5){
xInit = xSpacer * 4;
}
else{
xInit = xSpacer;
}
for (float x = xInit; x <= width-xSpacer; x += xSpacer){
unidad(x,y);
counter ++;
println(counter+"/"+total);
}
}
printCode();
endRecord();
println("listo");
exit();
}
void unidad(float x, float y){
int achurados = 6; // num. de achurados por unidad
pushMatrix();
{
translate(x,y);
scale(0.45);
for(int i = 0; i < achurados; i++){
float xRange = random (-10, 10); // rango de juego horizontal
float yRange = random (-10, 10); // rango de juego vertical
achure(xRange, yRange);
}
}
popMatrix();
}
void achure (float _x, float _y){
float angulo = random(-HALF_PI);
float alto = random(2, 20);
float largo = random(2, 40);
int numLines = (int)random(2, 10);
float ySpacer = alto/float(numLines);
float xOffset = 155.0;
float st = random(0.1, 1.5);
float alfa = random(130, 200);
float zoom = random (100, 200);
float noiseAmp = random(largo, largo*5);
float o = 1445.25;
float u = 1232.345;
noFill();
strokeWeight(st);
stroke(0, alfa);
pushMatrix();
{
translate(_x, _y);
rotate(angulo);
for (float y = -alto; y <= alto; y += ySpacer){
float xNoise1 = noise ((y+o)/zoom) * xOffset;
float xNoise2 = noise ((y+u)/zoom) * xOffset;
beginShape();
for (float x = -(largo + xNoise1); x < (largo + xNoise2); x += 2){
float yNoise = noise ((x+o)/zoom, (y+o)/zoom) * noiseAmp;
vertex(x,y-yNoise);
}
endShape();
}
}
popMatrix();
}
void printCode(){
float interlin = 9.5;
float yInit = height*0.6;
fill(#C10202);
textFont(courier, 8);
for (int i = 0; i < code.length; i++){
text(code[i], 100, yInit+(interlin*i));
}
}
bajar lámina de ejemplo