# Ghosts (1000 lines)

For this part of the assignment I wanted to use for loops to make a complex, ghastly shape to be placed in a dark background. In some ways I find it successful, but I would like to get the movement a little more “floaty” than it currently is.

```  ##Will Taylor ## Ghosts (1000 Liner) width, height = 800,800 radius = 100 circleXY = [[int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))], [int(random(width)), int(random(height))]] def setup(): background(255,200) size(width,height) frameRate(24)   def draw(): background(0,10) fill(0,120); rect(0,0,width,height); smooth() strokeWeight(1) stroke(0)     def checkMatch(): for i in xrange(len(circleXY)): x = circleXY[i][0] y = circleXY[i][1] if (x == mouseX and y == mouseY): background(0) return True     def drawCircles(): rad = radius for i in xrange(0, len(circleXY)): stroke(2) fill(255,10) for x in xrange(len(circleXY) - i): if x%2 == 0: ellipse(circleXY[i][0], circleXY[i][1], rad-4*x, rad+4*x) ellipse(circleXY[i][0], circleXY[i][1], rad+4*(x+1), rad-4*(x+1)) else: ellipse(circleXY[i][0], circleXY[i][1], rad+4*x, rad-4*x) ellipse(circleXY[i][0], circleXY[i][1], rad-4*(x+1), rad+4*(x+1))                 def updateCircleX(): for i in xrange(len(circleXY)): if (circleXY[i][0] &gt; mouseX): circleXY[i][0] -= int(2*(i+1)%4 + (i+1)) elif (circleXY[i][0] &lt; mouseX): circleXY[i][0] += int(2*(i+2)%4 + (i+1))   def updateCircleY(): vChase = 1 for i in xrange(len(circleXY)): if (circleXY[i][1] &gt; mouseY): circleXY[i][1] -= int(2*(i+1) - i) elif (circleXY[i][1] &lt; mouseY): circleXY[i][1] += int(2*(i+1) - i)   def updateCircles(): updateCircleX() updateCircleY()   drawCircles()   updateCircles() checkMatch()```

# Hologram Particles (1000 lines)

``````//////////////////
// Hologram Particles
// Author: Matthew Kellogg
// October 6, 2014
//////////////////

//globals and constants
var particles = {};
var size;
var backgroundColor;
var attractDist = 200.0;
var repelDist = 20.0;
var numberParticles = 250;
var particleSpeed = 20.0;
var trails;

//Constructor for particle
function Particle(x,y){
this.pos = createVector(x,y);
this.vel = createVector(random(-10.0,10.0),random(-10.0,10.0));
this.color = color(random(20,40), random(100, 255), random(100,255));
this.force = createVector(0.0,0.0);
}

function setup() {
createCanvas(800, 600);
// create a graphic object the size of the screen to do
// trail blur that doesn't match particles
trails = createGraphics(width, height);

//backgroundColor = color(100,100,160, 20);
size = 5;

// construct the particles
for (var i = 0; i< numberParticles; i++)
{
particles[i] = new Particle(random(0,width),random(0,height));
}
}

function draw() {
// update the particle positions
updateParticles();

/*trails.fill(backgroundColor);
trails.noStroke();
trails.rect(0,0,width,height);

// Draw each particle on the trails image
for (var i = 0; i< numberParticles; i++)
{
var p = particles[i];
trails.fill(p.color);
trails.ellipse(p.pos.x, p.pos.y, size, size);
}

//draw the trails image to the window
image(trails,0,0);*/

//draw each particle with an outline on the window
// this doesn't affect the trails image
// I've considered making the particles into triangles
// to emphasize that.
clear();
background(0);
strokeWeight(1);
for (var i = 0; i< numberParticles; i++)
{
var p = particles[i];
fill(p.color);
stroke( red(p.color)/3.0, green(p.color)/3.0, blue(p.color)/3.0);
lineThrough(p.pos.x,0,p.pos.x, p.pos.y);
lineThrough(0,p.pos.y,p.pos.x, p.pos.y);
lineThrough(-p.pos.y,-p.pos.x,p.pos.x, p.pos.y);
lineThrough(p.pos.y,-p.pos.y, p.pos.x, p.pos.y);
noStroke();
ellipse(p.pos.x,p.pos.y, size, size);
}
}

function lineThrough(x1, y1, x2, y2){
if (x1 == x2){
line(x1, 0, x1, height);
}
var x0 = 0.0;
var m = 1.0 * (y2 - y1) / (x2 - x1);
var y0 = m * (- x1) + y1;
if (y0 < 0 || y0 > height){
// change x0 and y0 to x intercept
}
var x3 = width * 1.0;
var y3 = m * (width - x1) + y1;
if (y3 < 0 || y3 > height){
// change x0 and y0 to x intercept
}
line(x0, y0, x3, y3);
}

// this function updates the particles forces, speeds, and position
function updateParticles(){
// the particle speed is mapped from the mouse position
particleSpeed = map(mouseX, 0, width, 100.0, 1000.0);
particleSpeed = constrain(particleSpeed, 100.0, 1000.0);

//zero forces
for (var i = 0; i< numberParticles; i++)
{
var p = particles[i];
p.force.set(0.0,0.0);
}

// calculate forces between each pair of particle
for (var i = 0; i< numberParticles; i++)
{
var p = particles[i];
for (var j = i + 1; j< numberParticles; j++)
{
var p2 = particles[j];
//vector of the difference between the two particles
var diff = wrapSub(p2.pos, p.pos);
var magSq = diff.magSq();
// when close enough particles should avoid each other
if (magSq < repelDist*repelDist){
//repulsion is 2/3 the force of attraction
var force = diff.div(sqrt(magSq)).mult(-2.0);
}
// when not close enough to repel, but within some distance
// particles should attract each other
else if (magSq < attractDist*attractDist)
{
var force = diff.div(sqrt(magSq)).mult(3.0);
}
}

//normalize velocity
var mag = p.vel.mag();
p.vel.div(mag);

//normalize force
mag = p.force.mag();
p.force.div(mag);

//gives 9 to 1 contribution of force and previous velocity

// set speed
p.vel.mult(particleSpeed);

// wrap around
p.pos.x = wrap(p.pos.x, -size, width + size);
p.pos.y = wrap(p.pos.y, -size, height + size);
}
}

// wraps vector difference around edges of screen
function wrapSub(p1, p2){
var p = createVector(0,0);
p.x = wrap(p1.x - p2.x, 0, width);
p.y = wrap(p1.y - p2.y, 0, height);
return p;
}

// wraps value about min and max
function wrap(val, min, max){
return ((((val - min) % (max - min)) + (max - min)) % (max - min)) + min;
}``````

For this project I wanted to use the 1000 lines to create a hologram effect where the particles would be apparent based on the intersection of lines through the particles. I also wanted to use additive lighting.

# more than 1000 lines

clair chin 1000 lines

float speed = 0.05;
float y=-400;
float x=0;

void setup() {
size(400, 400);
smooth();
}

void draw(){
int stagger = 0;
background(0);
stroke(255);
for (int j= 0; j < 2* height;j=j+height/20){
if (stagger==5){
stagger=0;}
else {
stagger=5;}
for(int i=0; i < width;i = i + width/40){
line(x+i+stagger,y+j,x+i+stagger,y+j+15);
if (y>0) {
y = -400;
}
}
y= y+speed;
}
int cx=mouseX;
int cy=mouseY-15;
int rectx=cx-15;
int recty=cy;
noStroke();
fill(255);
ellipse(cx,cy,30,30);
fill(0);
stroke(0);
rect(rectx,recty,30,420);
stroke(255);
line(cx,cy,cx,cy+20);
}

# Clock : Distortion

My clock concept underwent some serious changes as it progressed. At first, my plan was to have a city which built itself and then destroyed itself every 24 hours, as shown in the schematics below:

Using toxiclibs, I managed to create a class which would create a flat plane in 3D space. As time progressed, boxes would emerge from the plane and grow upwards to a predetermined stop height. The problem was that if the plane was slanted in any direction, the boxes would still go straight up. I spent roughly 12 hours trying to fix this, but without any specific plan or debugging methodology, I only managed to waste loads of time and create more errors with the box generation. I ditched the idea of boxes for lines, which were much less time consuming to deal with. In the end, I managed to create a class which would accept any mesh, and generate lines which grow out of the given mesh in a specific direction. Thus, when a mesh that looks like this:

is fed into the class, this is the result:

captured in motion:

I inserted a shape into a 3D environment:

Originally, I planned to make the lines simply grow in different directions based on the time of day, but that didn’t seem to involve the surrounding terrain at all. Instead, I raised the shape high above the land, and altered the topography:

The beam of light moves to predetermined points (the intersections of the crevices between hills) around the terrain once per minute. A sped up section of random movement is shown here:

While at these points, the light will distort the surface of the terrain in one of five ways:

Every hour, the mesh is reset. One can look at the mesh and, judging its degree of distortion, tell how far into the current hour one is. Implementing a way to tell which hour is the next step, but currently this is only a one hour clock.

Here is a timelapse of the clock in action:

Code:

```import toxi.color.*; import toxi.color.theory.*; import toxi.physics2d.constraints.*; import toxi.physics.*; import toxi.physics.constraints.*; import toxi.physics.behaviors.*; import toxi.math.conversion.*; import toxi.geom.*; import toxi.math.*; import toxi.util.datatypes.*; import toxi.util.events.*; import toxi.geom.mesh.subdiv.*; import toxi.geom.mesh.*; import toxi.math.waves.*; import toxi.util.*; import toxi.math.noise.*; import java.util.*; import toxi.processing.*; import java.util.*;   import processing.opengl.*; int timeChange; Viewer v; Mesh3D shape; ToxiclibsSupport gfx; SuperStructure struc; VerletPhysics world; Land land; Agent3D zapPos; int imginc, curMin, curHour; void setup(){ size(1700,1000,OPENGL); v = new Viewer(-1280,-776,-1109, new Vec3D()); struc = new SuperStructure(0,-1000,0,(TriangleMesh)new AABB(20).toMesh(),new Vec3D(0,1,0),100,83,2000,1); gfx = new ToxiclibsSupport(this); world = new VerletPhysics(); land = new Land(0,50,0,new Vec3D()); imginc = 0; timeChange = 0; zapPos = new Agent3D(0,0,0,new Vec3D()); zapPos.maxSpeed = 15.0; zapPos.maxForce = 5.0; curMin = minute(); curHour = hour(); zapPos.setSeekPt(land.marks.get(int(random(land.marks.size())))); struc.zapPoint(zapPos); }   void draw(){ noCursor(); background(30,40,90);   if(curMin != minute()){ zapPos.setSeekPt(land.marks.get(int(random(land.marks.size())))); struc.zapPoint(zapPos); curMin = minute(); land.changeRule(int(random(5))); imginc++; } if(curHour != hour()){ land.reconfiguring = true; curHour = hour(); }   world.update(); zapPos.run(gfx); Vec3D lightPos = struc.interpolateTo(zapPos,0.8); pointLight(220,180,200,lightPos.x,lightPos.y,lightPos.z); noStroke(); struc.run(gfx); land.run(gfx); v.run(); if(key == 'c'){ println(v.campos, v.direction); } } class Agent3D extends VerletParticle{ Vec3D targ, direction; TriangleMesh shape; float maxSpeed, maxForce; Agent3D(float x, float y, float z){ super(x,y,z); direction = null; shape = new TriangleMesh(); targ = null; maxSpeed = 5.0; maxForce = 1.2; } Agent3D(float x, float y, float z, Vec3D rot){ this(x,y,z); direction = rot; } Agent3D(float x, float y, float z, Vec3D rot, TriangleMesh shape){ this(x,y,z,rot); this.shape = shape; } void setSeekPt(Vec3D target){ targ = target; } void setDirectionToFace(Vec3D pt){ direction.set(this.sub(pt).normalize()); } void seek(){ if(targ != null){ Vec3D c = this.sub(targ); float m = map(c.magnitude(),0,100,0,maxSpeed); c = c.normalizeTo(m); Vec3D steer = this.getVelocity().sub(c); steer = steer.limit(maxForce); this.addVelocity(steer); } }   void display(ToxiclibsSupport tls){ tls.translate(this); shape = shape.pointTowards(direction); tls.mesh((Mesh3D)shape, false); tls.translate(new Vec3D().sub(this)); } void run(ToxiclibsSupport tls){ seek(); update(); display(tls); clearVelocity(); } } class SuperStructure extends Agent3D{ int timeOfBirth, age, maxAge, maxBlocks; Structure[] structs; SuperStructure(float x, float y, float z, Mesh3D m, Vec3D dir, int lifespan, int blockNum, int blockH, int blockW){ super(x,y,x,dir); maxBlocks = blockNum; maxAge = lifespan; shape = (TriangleMesh)new STLReader().loadBinary(sketchPath("god.stl"),STLReader.TRIANGLEMESH); structs = new Structure[m.getFaces().size()]; for(int i = 0; i < structs.length; i++){ Face f = (Face)m.getFaces().toArray()[i]; structs[i] = new Structure(this.x,this.y,this.z,this.direction, blockH, maxAge, blockW, blockH, maxBlocks, f); } } void zapPoint(Vec3D pt){ setDirectionToFace(pt); for(Structure s: structs){ s.setDirectionToFace(pt); } } void run(ToxiclibsSupport tls){ zapPoint(zapPos); for(Structure s: structs){ if(s != null){ s.grow(); } } fill(255); this.display(tls); } }   class Structure extends Agent3D{ float baseRadius, maxBlockWidth, maxBlockHeight, blockWidth, blockHeight; int timeOfBirth, age, maxAge, maxBlockNum, blockSlot, lifeStage; Block[] blocks; Triangle3D base;   Structure(float x, float y, float z, Vec3D dir, float top, int lifespan, float wid, float hei, int blockNum, Face baseMake){ super(x,y,z,dir); timeOfBirth = frameCount; maxBlockWidth = wid; blockSlot = 0; maxBlockHeight = hei; maxBlockNum = blockNum; maxAge = lifespan; blocks = new Block[maxBlockNum]; base = new Triangle3D((Vec3D)baseMake.a, (Vec3D)baseMake.b, (Vec3D)baseMake.c); for(int i = 0; i < maxBlockNum; i++){ Vec3D newPoint = base.a.interpolateTo(base.b.interpolateTo(base.c,random(1)),random(1)); blocks[i] = new Block(newPoint.x,newPoint.y,newPoint.z,direction,maxBlockWidth,maxBlockHeight,(int)random(maxAge)); } } void setDirectionToFace(Vec3D pt){ direction = pt.sub(this).normalize(); } Triangle3D buildBase(){ Vec3D[] corners = new Vec3D[3]; for(int i = 0; i < 3; i++){ //creates corners by making flat random vector and then rotating to match structures rotation Vec3D newCorner = new Vec3D(random(-1,1)*baseRadius,0,random(-1,1)*baseRadius).rotateX(direction.x).rotateY(direction.y); corners[i] = newCorner; } return new Triangle3D(corners[0],corners[1],corners[2]); } void grow(){ gfx.translate(this); for(int i = 0; i < maxBlockNum; i++){ Block b = blocks[i]; b.grow(); b.display(gfx); if(frameCount-b.birth > b.maxAge){ Vec3D newPoint = base.a.interpolateTo(base.b.interpolateTo(base.c,random(1)),random(1)); blocks[i] = new Block(newPoint.x,newPoint.y,newPoint.z,direction,maxBlockWidth,maxBlockHeight,maxAge); } } gfx.translate(new Vec3D().sub(this)); } }   class Block extends Agent3D{ float wdth, hght; int tone, birth, maxAge; TColor col; Vec3D up; Vec3D box; Block(float x,float y,float z,Vec3D rot, float wt, float ht,int maxAge){ super(x,y,z,rot); birth = frameCount; this.maxAge = maxAge; wdth = wt; hght = ht; box = blockFace(); tone = int(noise(frameCount*0.03)*30); }   Vec3D blockFace(){ return this.add(direction.normalizeTo((frameCount+1-birth)*1.0/maxAge*hght)); }   void grow(){ box = blockFace(); } void display(ToxiclibsSupport tls){ strokeWeight(wdth); stroke(180,180,200,tone); tls.line(this,box); } } class Viewer{ Vec3D direction, campos; Viewer(float x, float y, float z, Vec3D dir) { direction = dir; campos = new Vec3D(x,y,z); }   void run() { direction.set(sin(map(mouseX,0,width,2*PI,0)),map(mouseY,0,height,-1.5,1.5),cos(map(mouseX,0,width,2*PI,0))); direction.addSelf(campos);   // Change height of the camera with mouseY camera(campos.x, campos.y, campos.z, // eyeX, eyeY, eyeZ direction.x, direction.y, direction.z, // centerX, centerY, centerZ 0.0, 1.0, 0.0); // upX, upY, upZ if(keyPressed){ Vec3D dir = direction.copy(); dir.subSelf(campos); switch(key){ case('a'): dir.set(sin(map(mouseX,0,width,2.5*PI,PI/2)),0,cos(map(mouseX,0,width,2.5*PI,PI/2))); campos.addSelf(dir.normalizeTo(3)); break; case('w'): campos.addSelf(dir.normalizeTo(3)); break; case('d'): dir.set(sin(map(mouseX,0,width,2.5*PI,PI/2)),0,cos(map(mouseX,0,width,2.5*PI,PI/2))); campos.subSelf(dir.normalizeTo(3)); break; case('s'): campos.subSelf(dir.normalizeTo(2)); break; } } } } class Land extends Agent3D{ TriangleMesh originalShape; Terrain terrain; ArrayList<Agent3D> marks; int ruleNum; boolean reconfiguring; float reconfigRatio; float xCenter = 5.2; float zCenter = 5.2; Land(float xx,float yy,float zz, Vec3D dir){ super(xx,yy,zz,dir); marks = new ArrayList(); int DIMS = 40; reconfiguring = false; reconfigRatio = 0.0; terrain = new Terrain(DIMS,DIMS, 50); float[] el = new float[DIMS*DIMS]; noiseSeed((long)random(500)); ruleNum = int(random(5)); for (int z = 0, i = 0; z < DIMS; z++) { for (int x = 0; x < DIMS; x++) { el[i++] = noise(x * 0.12, z * 0.12) * 400/PApplet.max((PApplet.abs(xCenter - (x%10))*PApplet.abs(zCenter-(z%10))),4); if((x+5)%10 == 0 && (z+5)%10 == 0){ IsectData3D sec = new IsectData3D(); sec = terrain.intersectAtPoint(x,z); marks.add(new Agent3D(sec.pos.x()*50-1000,150,sec.pos.z()*50-1000,new Vec3D())); } } } terrain.setElevation(el); // create mesh shape = (TriangleMesh)terrain.toMesh(); originalShape = shape.copy(); } void display(ToxiclibsSupport tls){ noStroke(); super.display(tls); stroke(255,0,0); }   void run(ToxiclibsSupport tls){ if(reconfiguring) { reconfigure(); } super.run(tls); for(Agent3D mark: marks){ mark.run(tls); } alterTerrain(zapPos); }   ArrayList<Vec3D> getVertexPoints(TriangleMesh s){ ArrayList<Vec3D> start = new ArrayList(); Iterator<Vertex> getter = shape.getVertices().iterator(); while(getter.hasNext()){ start.add((Vec3D)getter.next()); } return start; }   ArrayList<Vec3D> getCloseVertices(Vec3D pt){ ArrayList<Vec3D> result = new ArrayList(); Vec3D ptFlat = new Vec3D(pt.x,0,pt.z); ListIterator<Vec3D> remover = getVertexPoints(shape).listIterator(); while(remover.hasNext()){ Vec3D f = (Vec3D)remover.next(); Vec3D flat = new Vec3D(f.x,0,f.z); if(flat.distanceToSquared(ptFlat) < 10000){ result.add(f); } } return result; }   Vec3D average(ArrayList<Vec3D> vecs){ Vec3D result = new Vec3D(); for(Vec3D v: vecs){ result = result.add(v); } return result.scale(1.0/vecs.size()); }   void reconfigure(){ shape = originalShape.copy(); reconfiguring = false; }   void changeRule(int r){ ruleNum = r; }   void alterTerrain(Agent3D cursor){ for(Agent3D mark: marks){ if(cursor.distanceToSquared(mark) < 4){ ArrayList<Vec3D> nearPts = getCloseVertices(cursor); for(Vec3D pt: nearPts){ Vec3D rule = new Vec3D(); switch(ruleNum){ case(0): rule = pt.sub(average(nearPts)); break; case(1): rule = average(nearPts).sub(pt); break; case(2): rule = new Vec3D(cos(second()*PI/30),sin(second()*PI/15),sin(second()*PI/30)); break; case(3): rule = new Vec3D(pt.sub(struc)); break; case(4): rule = new Vec3D(struc.sub(pt)); break; } shape.updateVertex(pt, pt.add(rule.normalizeTo(2))); } mark.setSeekPt(average(getCloseVertices(cursor))); } } } }```

Comments Off on Clock : Distortion

# One Thousand Liners

Years passed and the colony of my creations flourished. But a great xenophobia emerged. Intruders were immediately caught and exiled. The lines were finally left in peace.

```import java.awt.Robot; import java.awt.AWTException; import processing.serial.*; import java.awt.MouseInfo; import java.awt.Point;   Robot rob;   ArrayList<ZoomLine> lines;   boolean mouseInWindow;   void setup() { size(700,500); lines = new ArrayList<ZoomLine>(); createLines(); //Set up Bot to move mouse try { rob = new Robot(); } catch (AWTException e) { e.printStackTrace(); } }   void draw() { background(255); mouseInWindow(); moveMouse(); updateLines(); }   void moveMouse() { if (mouseInWindow){ float distance = dist(mouseX,mouseY,width/2,height/2); float speed = 3; int x = frame.getLocation().x; int y = frame.getLocation().y; float xChange; float yChange; if (mouseX < width/2) { xChange = -1; } else { xChange = +1; } if (mouseY < height/2) { yChange = 1; } else { yChange = -1; } rob.mouseMove((x + mouseX),(int) (y + mouseY)); } }   void createLines() { for (int i = 0; i < 100; i++) { // Top Left to center lines.add(new ZoomLine(0,0,width*.75,height*.5,false,-50,-50,0,0)); } for (int i = 0; i < 100; i++) { //Top right to center lines.add(new ZoomLine(width,0,width*.75,height*.5,false,50,-50,0,0)); } for (int i = 0; i < 100; i++) { //Bottom Right to Center lines.add(new ZoomLine(width,height,width*.75,height*.5,false,50,50,0,0)); } for (int i = 0; i < 100; i++) { //Bottom Left to Center lines.add(new ZoomLine(0,height,width*.75,height*.5,false,-50,50,0,0)); } for (int i = 0; i < 100; i++) { //Top bar lines.add(new ZoomLine(width/2 + 50,height/2 - 50, width/2 - 50,height/2 - 50 ,true,-50,-50,50,-50)); } for (int i = 0; i < 100; i++) { //Right Bar lines.add(new ZoomLine(width/2 + 50,height/2 + 50, width/2 + 50,height/2 - 50 ,true,+50,-50,50,50)); } for (int i = 0; i < 100; i++) { // Left Bar lines.add(new ZoomLine(width/2 - 50,height/2 - 50, width/2 - 50,height/2 + 50 ,true,-50,+50,-50,-50)); } for (int i = 0; i < 100; i++) { //Bottom Bar lines.add(new ZoomLine(width/2 - 50,height/2 + 50, width/2 + 50,height/2 + 50 ,true,+50,+50,-50,+50)); } for (int i = 0; i < 50; i++) { //Top center to center lines.add(new ZoomLine(width/2,0,height/2,height/2 - 50,false,0,-50,0,0)); } for (int i = 0; i < 50; i++) { //Left to center lines.add(new ZoomLine(0,height/2,width/2 - 50,height/2,false,-50,0,0,0)); } for (int i = 0; i < 50; i++) { //Bottom to center lines.add(new ZoomLine(width/2,height,width/2,height/2 + 50,false,0,50,0,0)); } for (int i = 0; i < 50; i++) { //Right to center lines.add(new ZoomLine(width,height/2,width/2 + 50,height/2,false,50,0,0,0)); } }   void updateLines() { for (int i = 0; i < lines.size(); i++) { lines.get(i).update(); lines.get(i).drawMe();   } }   class ZoomLine { Position start; Position lineLoc; Position lineEnd; Position goal;   Position velocity;   float lineLength; float angle;   boolean moving;   float noiseStart = random(100); float noiseChange = .007;   float speed;   float offSetX; float offSetY;   float mouseOffX; float mouseOffY;   float startOffX; float startOffY;   ZoomLine(float startX, float startY, float goalX, float goalY, boolean moving, float mouseOffX, float mouseOffY, float startOffX, float startOffY) {   this.start = new Position(startX, startY); this.goal = new Position(goalX, goalY);   this.mouseOffX = mouseOffX; this.mouseOffY = mouseOffY;   this.startOffX = startOffX; this.startOffY = startOffY;   this.moving = moving; this.speed = 5;   this.lineLoc = pointBetween(this.start.x, this.start.y, this.goal.x, this.goal.y); updateAngle(); updateLength(); updateLineEnd(); float largest = max(width,height); offSetX = random(-largest * .03,largest * .03); offSetY = random(-largest * .03,largest * .03); }   void updateSpeed() { float distance = dist(this.goal.x, this.goal.y, this.start.x, this.start.y); this.speed = distance / this.lineLength; }   void updateAngle() { float dx = this.goal.x - this.lineLoc.x; float dy = this.goal.y - this.lineLoc.y;   this.angle = atan2(dy,dx); }   void updateLength() { float distance = dist(this.goal.x, this.goal.y, this.start.x, this.start.y);   this.noiseStart += this.noiseChange;   this.lineLength = (distance * .3) * noise(this.noiseStart); }   Position pointBetween(float x1, float y1, float x2, float y2) { float w = random(0,1);   float xm = x1 * w + (1 - w) * x2; float ym = y1 * w + (1 - w) * y2;   return new Position(xm, ym); }   void updateLineEnd() { float yChange = sin(this.angle) * this.lineLength; float xChange = cos(this.angle) * this.lineLength; this.lineEnd = new Position(this.lineLoc.x + xChange, this.lineLoc.y + yChange); } void drawMe() { strokeWeight(4); line(this.lineLoc.x + offSetX, this.lineLoc.y + offSetY, this.lineEnd.x + offSetX, this.lineEnd.y + offSetY); }   void updateGoal() { if (mouseInWindow) { this.goal.x = mouseX + this.mouseOffX; this.goal.y = mouseY + this.mouseOffY; } else { this.goal.x = width/2; this.goal.y = height/2; } if ((this.moving) && (mouseInWindow)){ this.start.x = mouseX + this.startOffX; this.start.y = mouseY + this.startOffY; } } void update() { this.updateGoal(); this.updateAngle(); this.updateLineEnd(); this.move(); }   void move() { float distance = dist(this.lineLoc.x,this.lineLoc.y,this.goal.x, this.goal.y); this.lineLoc.x += this.speed*((this.goal.x - this.lineLoc.x)/distance); this.lineLoc.y += this.speed*((this.goal.y - this.lineLoc.y) / distance);   if (dist(this.lineLoc.x, this.lineLoc.y,this.goal.x, this.goal.y) <= width * .02) { this.lineLoc.x = this.start.x; this.lineLoc.y = this.start.y; this.updateLength(); this.updateSpeed(); } } }   void mouseInWindow() { Point mousePos = (MouseInfo.getPointerInfo().getLocation()); int mWinX = mousePos.x; int mWinY = mousePos.y; int fX = frame.getLocation().x; int fY = frame.getLocation().y; if ((mWinX > fX && mWinX < fX + width) && (mWinY > fY && mWinY < fY + height)) { mouseInWindow = true; } else { mouseInWindow = false; } }   class Position { float x; float y; Position(float x, float y) { this.x = x; this.y = y; } }   class RandomPosition extends Position { RandomPosition(float startX, float endX, float startY, float endY) { super(random(startX, endX),random(startY, endY)); } }```

# Thousand Lines: (Another) Mandala

Another mandala, similar to my clock mandala…Semi-unpredictable patterns created by mashing variables and loops around. It can be spun with the mouse (and there’s some simple smoothing so you can kind of ‘throw’ it).

``````var m = 0;

function setup() {
createCanvas(700,700);
}

function draw() {
background(150,150,150);

var rawm = mouseX + millis()*0.0001;
m += (rawm-m)/20;

for(var i = 0; i < 50; i++) {
for (var j = 0; j < 360; j+=18) {
var lx = cos(j+i*m*0.01)*5*i + 350;
var ly = sin(j+i*m*0.01)*5*i + 350;

var lx2 = lx + cos(m*0.01+i+j)*i*2;
var ly2 = ly + sin(m*0.01+i+j)*i*2;

strokeWeight((50-i)/20);
line(lx,ly,lx2,ly2);
}
}
}
``````

# Alex Thousand Liner

Rain Bow

For this prompt, I wanted it to rain and every time. your mouse was over a raindrop, It would change color. I was successfully able to create 100o falling rain drops and make them change color when the mouse was on one. However, I did not know how to make the drops fall at different intervals
so they all fall together. If I would work more on this project I would have them fall at different intervals and possibly have them avoid the cursor.

```int radius = 2;
float speed = 3;
void setup() {
size(1000, 200);
smooth();
}
void draw() {
float r=random(0,255);
float g=random(0,255);
float b=random(0,255);

fill(50,50,50,10);
rect(0,0,1000,200);

y += speed;
if (y > height) {
}
for (int i=2; ii) && (mouseX
```

# csb – 1000 lines –

Warning: file_get_contents(http://cmuems.com/2014a/wp-content/uploads/2014/10/sketch7.js data-height=): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /nfs/c05/h04/mnt/77459/domains/cmuems.com/html/2014a/wp-content/plugins/p5-embedder/p5-embedder.php on line 57

# 1000 Lines: The Red Sea

A sea that is sometimes red, but not often.

this is an ocean build of undulating lines, that slowly change colour with time. Introducing the mouse causes these lines to move, shifting against the movement of the mouse, letting the controller mark their own light trails in the ‘water’.

code:

```//The Red Sea. I want to see The Red Sea on a wall.   //class of each light bar that appears onscreen class Bar{ int ix; int iy; int sx; int sy; int ex; int ey; color c;   Bar(int tempix, int tempiy, int tempsx, int tempsy, int tempex, int tempey, color tempc){ int rx = int(random(-20,20)); int ry = int(random(-10,10)); ix = tempix; iy = tempiy; sx = tempsx + rx; sy = tempsy + ry; ex = tempex + rx; ey = tempey + ry; c = tempc; }   //colours are based off of noise and realtive position, so each //colurs shift in slight uinson. void update(float t){ c = color(255*noise(ix/20.0,iy/20.0, t/2.0), 255*noise(ix/20.0 + 5,iy/20.0 + 5, t/20.0 + 5), 255*noise(ix/20.0 + 10,iy/20.0 + 10, t/400.0 + 10)); }   //draws with mouse accounted for. Some trig is used to make the //waves void display(float t){ stroke(c); strokeWeight(2); int sx2 = sx - (mouseX - sx)/4; int sy2 = sy - (mouseY - sy)/5; int ex2 = ex - (mouseX - ex)/5; int ey2 = ey - (mouseY - ey)/6; line(sx2 + 4*cos(ix/10.0+iy/10.0-t), sy2 + 10*sin(ix/10.0+iy/10.0-t), ex2 + 2*cos(ix/10.0+iy/10.0-t), ey2 + 10*sin(ix/10.0+iy/10.0-t)); } }   ArrayList<Bar> bars;   //creates the bars semi-randomly void setup(){ size(1800,500); bars = new ArrayList<Bar>(); int dw = width/100; int dh = height/10; for (int x = 0; x < 100; x++){ for(int y = 0; y < 10; y++){ bars.add(new Bar(x,y, dw*(x)+int(50*(noise(x/20.0 + 10,y/20.0 + 10)-0.5)), dh*(y)+int(50*(noise(x/20.0 + 5,y/20.0 + 5)-0.5)), dw*(x)+5+int(50*noise(x/20.0,y/20.0) - 0.5), dh*(y)+50+int(50*noise(x/20.0 - 5,y/20.0 - 5)-0.5), color(255,0,0))); } } noStroke();   fill(0,0,0); rect(0,0,width,height); }   //draws with low-alpha background, to allow for blur, and adds any //time-based trig movement and mouse movement void draw(){ //background(0,0,0, 200); noStroke(); fill(0,0,0,3); rect(0,0,width,height); float t = millis()/1000.0; for (int i = bars.size()-1; i >= 0; i--) { Bar bar = bars.get(i); bar.update(t); bar.display(t); } }```

# 1000 lines

This was an edit of my hallway/10 lines. I was hoping to use the camera function in this one, but was unsuccessful in getting it to work.

```    float winX; float lineCol, backgroundCol; float startPoint; float winSpeed; void setup() { size(700, 700, P3D); winX= width/7; lineCol=0; backgroundCol=255; startPoint=-2500; } void draw() { noStroke(); background(backgroundCol); if (winSpeed > 5300){ winSpeed=startPoint; } winSpeed=winSpeed+20; for (int h=1; h < 125 ;h++) { moveZ(winX-(h*2), height/2, startPoint+h*2, winSpeed+sqrt(h)); } if (pmouseX < mouseX && winSpeed > 3000 && winSpeed < 3400 ){ strokeWeight(sqrt(winSpeed/100)); if( backgroundCol == 255 ) while (backgroundCol > 0 ) {backgroundCol= backgroundCol-10; } if( backgroundCol == 0 ) while (backgroundCol < 255 ) {backgroundCol= backgroundCol+10; } if( lineCol == 255 ) while (lineCol > 0 ) {lineCol= lineCol-10; } if( lineCol == 0 ) while (lineCol < 255 ) {lineCol= lineCol+10; } } } void moveZ(float x, float y, float z, float speed) { z = z + speed; drawDoors(x*2, y, z);//left door drawDoors(x*5, y, z+50);//rightdoor } void drawDoors(float x, float y, float z) { float speed=10; float side = 103; stroke(lineCol); strokeWeight(winSpeed); line(x, y+100, z+50, x, y+100, z-50); line(x, y+side, z-50, x, y-side, z-50); line(x, y-100, z-50, x, y-100, z+50); line(x, y-side, z+50, x, y+side, z+50); // beginCamera(); // camera(x,y,z+speed,x,y,z+speed, 0, 1, 0); // endCamera(); }```