Processing code printed on Plexi Glass
Created code on processing:
ArrayList<Agent> agents;
//Import librarie
import org.philhosoft.p8g.svg.P8gGraphicsSVG;
//Define an SVG object
P8gGraphicsSVG svg;
void setup()
{
size(600, 600);
agents= new ArrayList();
for(int i = 0; i <100; i ++){
agents.add(new Agent() );
smooth();
//Define the name of your file
svg = (P8gGraphicsSVG) createGraphics(width, height, P8gGraphicsSVG.SVG, “motifG.svg”);
beginRecord(svg);
println(“Use letter S to save image and letter Q to quit the sketch”);
}
}
void draw(){
background(255);
for (int i = 0; i<agents.size(); i ++){
Agent myAgent = agents.get (i);
myAgent.update();
myAgent.display();
}
for (int i = 0; i <agents.size(); i ++){
for (int j= 0; j <i; j++){
//inner loop so we do not repeat pair test
Agent myAgentA= agents.get(i);
Agent myAgentB= agents.get(j);
float myDist= dist(myAgentA.x, myAgentA.y, myAgentB.x, myAgentB.y);
if (myDist<50){
float alpha= map(myDist,0,80, 0, 255);
stroke(0,255-alpha);
line(myAgentA.x, myAgentA.y, myAgentB.x, myAgentB.y);
}
}
}
}
class Agent{
float x;
float y;
float noiseX;
float noiseY;
Agent(){
x= random(width);
y= random(height);
noiseX= random(100);
noiseY= random(100);
}
void display (){
ellipse (x,y,3,3);
}
void update(){
x = width * noise(noiseX);
y = height* noise(noiseY);
noiseX += .003;
noiseY+= .003;
}
}
//Fonction to use the keyboard
void keyPressed()
{
if (key == ‘s’)
{
svg.endRecord();
println(“Saved.”);
}
else if (key == ‘q’)
{
svg.clear();
exit();
}
Saved the processing imageĀ as an SVG
placed the image in illustrator to change the lines into blue .001
and printed on plexi glass