# A Good ‘Ol Fashioned Rumble! (Ten Liner)

Uh oh, looks like there’s a rumble! Use your cursor to either flee the scene, or stay and fight. When the circles get closer together, the screen flashes to give the effect of punches being thrown. The biggest challenge I faced for this assignment was getting each circle to move at a different rate. The method I ended up using allows the speed of a circle to be faster if it was drawn towards the end of the for loop.

```##Will Taylor ## A Good 'Ol Fashioned Rumble (Ten Liner) width, height = 400,400 radius = 10 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(): size(width,height) frameRate(32)   def draw(): background(255) smooth() strokeWeight(2) 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(len(circleXY)): if (i &gt; len(circleXY)/2): stroke(0) fill(255) else: stroke(150) fill(0) ellipse(circleXY[i][0], circleXY[i][1], rad, rad);     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((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()```

# Dandilion (10 lines)

``````var dCenter;
var seeds = {};

function Seed(x, y, dir){
this.x = x;
this.y = y;
this.homeX = x;
this.homeY = y;
this.dir = dir;
this.len = 20;
}

function setup() {
createCanvas(600,400);
dCenter = createVector(200, height - 200);
for (var i = 0; i<9; i++){
angle = i*360.0/9.0;
}
prevMouseX = mouseX;
}

var wind = 0.0;
var prevMouseX;
function draw() {
wind = wind*0.9 + (mouseX - prevMouseX)*0.1;
prevMouseX = mouseX;
background(0);
stroke(255);
noFill();
translate(wind,0);
//ellipse(dCenter.x,dCenter.y, 40,40);
for (var i=0; i<9; i++){
var s = seeds[i];
}
translate(-wind,0);
// stem
line(150, height, dCenter.x+wind, dCenter.y);
}``````

For this project I wanted to make a flower blow in the wind. I wanted the mouse to blow the seeds off of the flower, and then have them wrap around the border and land back onto the flower. This turned out to be a bit more challenging than I had originally thought.

# sinWave 10 lines

clair chin

10 lines moving along sin wave with amplitude according to mouse X

``````<pre lang="java" line="1">

int startingX;
int increment;
float x;
float pi;

void setup()
{
size(800,300);
increment=width/11;
x=0;
pi=3.141592654;
}

void draw()
{
background(0);
println(x<2*pi);
if (x<2*pi)
{
x=x+(2*(pi/100));
}
else
{
x=0;
}
float waveLevel=map(mouseX,0,width,0,70);
for (int i=1;i<11;i++)
{
stroke(255);
float shift = sin(x+i*2*pi/10)*waveLevel;
line((increment*i),140+shift,(increment*i),155+shift);
}

}

</pre>``````

# Ten Lines: Divination

A p5.js Cleromancy system. Ten lines act as bones. Click to set all of the bones back to the center.

``````//     Cleromancy is a form of divination using
// sortition, casting of lots, or casting bones
// or stones, in which an outcome is determined
// by means that normally would be considered
// random, such as the rolling of dice, but are
// sometimes believed to reveal the will of God,
// or other supernatural entities.

function Bone(t,l) {
this.x = 200;
this.y = 200;
this.vx = 0;
this.vy = 0;
this.thickness = t;
this.angle = random(0,360);
this.va = 0;
this.len = l;
}

var bones = [];

function setup() {
createCanvas(400,400);
initBones();
}

function initBones() {
bones = [];

// spines
bones.push(new Bone(1,38));
bones.push(new Bone(2,33));
bones.push(new Bone(3,41));
// bulbs
bones.push(new Bone(5,16));
bones.push(new Bone(4,22));
bones.push(new Bone(4,22));
// primal
bones.push(new Bone(2,10));
bones.push(new Bone(1,6));
// pods
bones.push(new Bone(7,2));
bones.push(new Bone(4,1));
}

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

for(var i = 0; i < bones.length; i++) {
var b = bones[i];

// casting
var mdx = mouseX - b.x;
var mdy = mouseY - b.y;
if(abs(mdx) < 30 & abs(mdy) < 30) {
b.vx += random(-15,15);
b.vy += random(-15,15);
b.va += random(-2,2);
}

// movement
b.x += b.vx;
b.y += b.vy;
b.angle += b.va;

// friction
b.vx *= 0.9;
b.vy *= 0.9;
b.va *= 0.9;

// angle calc
var xo = cos(b.angle)*b.len;
var yo = sin(b.angle)*b.len;

// wall collision
if(b.x+xo > 400 || b.x+xo < 0 || b.x-xo > 400 || b.x-xo < 0) {
b.vx = -b.vx;
}
if(b.y+yo > 400 || b.y+yo < 0 || b.y-yo > 400 || b.y-yo < 0) {
b.vy = -b.vy;
}

// drawing
stroke(0,0,0);
strokeWeight(b.thickness);
line(b.x+xo,b.y+yo,
b.x-xo,b.y-yo);
}
}

function mousePressed() {
initBones();
}``````

# Ten Liners

Soon, he multiplied. Gathering new companions upon his plane, our one was now many. Together they inhabited the two-dimensional world they had been handed, but now they gained a true sense of ownership. One is timid, many are strong. Together they observe any and all intruders on their plain. They seek the knowledge their intruders hold.

```import java.awt.Robot; import java.awt.AWTException; import processing.serial.*; import java.awt.MouseInfo; import java.awt.Point;   Robot rob;   boolean allAlerted; ArrayList<LineMan> lineList; ArrayList<Position> atkPosList; ArrayList<Position> restPosList; ArrayList<Position> mouseHits; int lastUpdate; int timeWait; boolean oneAlerted;   void setup() { size(800,600); cursor(HAND);   //Set up Bot to move mouse try { rob = new Robot(); } catch (AWTException e) { e.printStackTrace(); } mouseHits = new ArrayList<Position>(); updateAtkPositions(); createRestPositions(); createLines(); allAlerted = false; lastUpdate = 0; oneAlerted = false;   }   void draw() { background(255); updatePositions(); mouseChecks(); updateLines(); drawLines(); }   void keyPressed() { //Get x,y of frame to offset changes. int x = frame.getLocation().x; int y = frame.getLocation().y; rob.mouseMove(x + width/2, y + height/2); }   void mouseChecks() { if (mouseInWindow() && !oneAlerted) { oneAlerted = true; alertClosest(); } else if (!mouseInWindow()) { oneAlerted = false; ignoreMouse(); } checkAlerted(); }   boolean 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)) { return true; } else { return false; } }   void alertClosest() { int closest = 0; int closestD = width; for (int i = 0; i < 10; i++) { if (dist(mouseX, mouseY, lineList.get(i).x, lineList.get(i).y) < closestD) { closest = i; } } lineList.get(closest).alerted = true; }   void ignoreMouse() { for (int i = 0; i < 10; i++) { lineList.get(i).alerted = false; } }   void updatePositions() { updateAtkPositions(); if ((millis() - lastUpdate)/1000.0 >= 1.5) { lastUpdate = millis(); updateRestPositions(); } }   void checkAlerted() { boolean check = true; for (int i = 0; i < 10; i++) { if (lineList.get(i).alerted == false) { check = false; allAlerted = false; break; } } if ((check)) { allAlerted = true; } }     void createLines() { lineList = new ArrayList<LineMan>(); for (int i = 0; i < 10; i++) { float x = random(width*.1, width*.9); float y = random(height * .1, height * .9); lineList.add(new LineMan(x,y,i)); } }   void updateAtkPositions() { atkPosList = new ArrayList<Position>(); float r = width * .07; // radius around mouse for (int i = 0; i < 10; i++) { float theta = i * (6.28 / 10 ); atkPosList.add(new Position(mouseX + (r * cos(theta)), mouseY + (r * sin(theta)) ) ); // This Code shows the attack positions // strokeWeight(5); // point(mouseX + r * cos(theta),mouseY + r * sin(theta)); } }   void createRestPositions() { restPosList = new ArrayList<Position>(); for (int i = 0; i < 10; i++) { float x = random(width * .15, width * .85); float y = random(height * .15, height * .85); restPosList.add(new Position(x,y)); }   }   void updateRestPositions() { for (int i = 0; i < 10; i++) { if (random(10) < 2) { restPosList.get(i).x = random(width*.15, width*.85); restPosList.get(i).y = random(height*.15,width*.85); } } }   void updateLines() { int count = 0; for (int i = 0; i < 10; i++) { lineList.get(i).update(); if (lineList.get(i).alerted){ count += 1; } } }   void drawLines() { for (int i = 0; i < 10; i++) { lineList.get(i).drawMe(); } }     class LineMan { float x; float y; float lineLength; float thickness; float headX; float headY; float bottomX; float bottomY; float distance; int index; float speed; Position atkPos; Position restPos; boolean attacking; boolean alerted; boolean inPlace; float yChange; float sinCurve; float sinCurveChange; float cosCurve; float cosCurveChange; float xChange;   LineMan(float x,float y,int index) { this.x = x; this.y = y; this.lineLength = (int)random(height * .05, height * .1); this.thickness = (int)random(2, 5); this.speed = max(width/4, height/4)/(this.lineLength * this.thickness); //Fatter lines move slower. this.headX = x; this.headY = y - lineLength/2; this.bottomX = x; this.bottomY = y + lineLength/2; this.alerted = false; this.update(); this.sinCurveChange = .1; this.cosCurveChange = 0; this.index = index; this.sinCurve = random(0, 6.28); this.cosCurve = random(0, 6.28); }   void drawMe() { strokeWeight(this.thickness); line(this.bottomX, this.bottomY, this.headX, this.headY); }   void update() { if ((allAlerted)) { this.attacking = true; } else { this.attacking = false; }   this.sinCurve += this.sinCurveChange; this.sinCurve = this.sinCurve % 6.28; this.cosCurve += this.cosCurveChange; this.cosCurve = this.cosCurve % 6.28; float coEff; float xCoEff;   if ((this.alerted) && (!this.attacking)) { coEff = .2; //Slow xCoEff = 2; this.cosCurveChange = .3; //Side to Side Motion } else if ((this.attacking) && (!this.inPlace)){ coEff = 10; //Fast xCoEff = 2; this.cosCurveChange = .3; //Side to Side Motion; } else if ((this.attacking) && (this.inPlace)) { coEff = 2; //Sort of Slow xCoEff = 2; this.cosCurveChange = .1; //Side to Side Motion; } else { coEff = 5; //No one on screen xCoEff = 0; this.cosCurveChange = 0; //Side to Side Motion }   if (this.alerted) { this.alertBuddy(); }   // CoEff... offset by height of window... sin wave this.yChange = coEff * (height / (float)400) * sin(this.sinCurve); this.xChange = xCoEff * (width / (float)400) * (cos(this.cosCurve)); this.definePos(); this.move(); }   void definePos() { this.atkPos = atkPosList.get(this.index); this.restPos = restPosList.get(this.index); if (this.attacking) { if ((abs(this.x - this.atkPos.x) <= width*.02) && (abs(this.y - this.atkPos.y) <= height*.02)) { this.inPlace = true; } else { this.inPlace = false; } } else { if ((abs(this.x - this.restPos.x) <= width * .02) && (abs(this.y - this.restPos.y) <= height * .02)){ this.inPlace = true; } else { this.inPlace = false; } } }   void move() { if ((this.attacking) && (!this.inPlace)){ float distance = dist(this.x, this.y, this.atkPos.x, this.atkPos.y); this.x += this.speed*(-((this.x - this.atkPos.x)/distance)); this.y += this.speed*(-((this.y - this.atkPos.y)/distance)); } else if ((!this.attacking) && (!this.inPlace)){ float distance = dist(this.x, this.y, this.restPos.x, this.restPos.y); this.x += this.speed*(-((this.x - this.restPos.x)/distance)); this.y += this.speed*(-((this.y - this.restPos.y)/distance)); } this.headX = this.x + this.xChange; this.headY = (this.y - lineLength/2) + this.yChange; this.bottomX = this.x + this.xChange; this.bottomY = this.y + lineLength/2 + this.yChange; }   void alertBuddy() { if (random(10) < .5) { lineList.get((int)random(10)).alerted = true; } }   }   class Position { float x; float y;   Position(float x, float y) { this.x = x; this.y = y; } }```

# TEN LINES

Move your mouse over the screen. Ten lines will reach out and grab your mouse from an invisible grid of circles. I drew this out in peak condition on paper beforehand, as seen below:

While there were some speed bumps navigating the javascript arrays, I was able to complete it exactly as I had initially envisioned:

``````var r;
var pts;
function setup() {
createCanvas(600,400);
r = width/9;
pts = [];
for(var i = 0; i < 15; i++){
var pX, pY;
var xOff = 0;
if(i<5){
pY = r;
}else{
if(i<10){
xOff = r;
pY = 3*r;
}
else{
pY = 5*r;
}
}
pX = (i%5)*2*r + xOff;
pts[i] = [pX,pY];
}
}

function draw() {
background(255);
var index = 0;
var xOffset = r;
if(mouseY > 2*r & mouseY < 4*r){
index += 5;
xOffset = 0;
}else if(mouseY > 4*r){
index += 10;
}
index += floor((mouseX+xOffset)/(2*r));
var circ = pts[index];
tenLines(circ[0],circ[1]);
}

function tenLines(x, y){
for(var i = 0; i < 10; i++){
var nX = x + r*cos(i*TWO_PI/10);
var nY = y + r*sin(i*TWO_PI/10);
line(mouseX,mouseY,nX,nY);
}
}``````

# 10 Lines: The Menhirs

Menhirs, also called standing stones, are a type of monolith found in Northern Europe. This is a minimal experiment in landscape generation using these objects as inspiration. They rotate with the mouse, and stones are added and remove by left and right clicking respectively.

code:

```//The Menhirs. Ignore the Aztec look.   ArrayList<Menhir> menhirs;   //seperately handles a menhir drawing void drawMenhir(int x,int y,int dw,int dh){ noStroke(); int ang = dw/4; fill(255); beginShape(); vertex(x+dw, y+dh-ang); vertex(x+dw/2, y+dh); vertex(x, y+dh-ang); vertex(x, y+ang); vertex(x+dw/2,y); vertex(x+dw,y+ang); endShape(); stroke(0); strokeWeight(3); beginShape(); vertex(x+dw,y+ang + 20); vertex(x+dw, y+dh-ang); vertex(x+dw/2, y+dh); vertex(x+dw/2,y+2*ang); vertex(x+dw,y+ang); vertex(x+dw/2,y); vertex(x, y+ang); vertex(x, y+dh-ang); endShape(); noFill();   }   //seperately draws the shadow of a menhir void drawShadow(int x,int y,int dw,int dh){ int ang = dw/4; stroke(0); noFill(); beginShape(); vertex(x, y+dh-ang); vertex(x-dh,y+dh-ang+(dh/2)); //here be logial derails vertex(x-dh+dw/10,y+dh-ang+(dh/2)+ang/5); vertex(x + dw/10, y+dh-ang + ang/5); vertex(x+ (2*dw/10), y+dh-ang +(2*ang/5)); vertex(x-dh+ (2*dw/10),y+dh-ang+(dh/2)+(2*ang/5)); vertex(x-dh+ (3*dw/10),y+dh-ang+(dh/2)+(3*ang/5)); vertex(x+ (3*dw/10), y+dh-ang +(3*ang/5)); vertex(x+ (4*dw/10), y+dh-ang +(4*ang/5)); vertex(x-dh+ (4*dw/10),y+dh-ang+(dh/2)+(4*ang/5)); vertex(x-dh+ (5*dw/10),y+dh-ang+(dh/2)+(5*ang/5)); vertex(x+ (dw/2) - ang , y+dh-ang + 3*ang/2); endShape();   }   // class that handles the standing stones class Menhir{ int x; int y; int trueY; int h; int w; float radius;   Menhir(){ x = 0; y = 0; trueY = 0; h = int(random(90,height/4)); w = int(random(30,width/8)); radius = map (noise(millis()), 0.0,1.0 , 0.0,0.6); }   //given an angle relative to the baseline (y = width/2), //places the menhir on that angle. void update(float ang){ x = width/2 + int(width*radius * cos(ang)); y = height/2 + int(height*radius * sin(ang)); trueY = y; if(mouseX < width/2) { x = width - x; y = height - y; } }   //I'm bad at code. void displayShadow(){ drawShadow(x,y,w,h); }   void display(){ drawMenhir(x,y,w,h); }   }   //creates the environment and the first menhir void setup(){ size(700,700); menhirs = new ArrayList<Menhir>(); menhirs.add(new Menhir()); }   //function that sorts the menhirs based on y position, so that //they can later drawn from front to back. //Zach Rispoli helped write this. ArrayList<Menhir> zjrispolsort(ArrayList<Menhir> menhirs){ ArrayList<Menhir> sorted = new ArrayList<Menhir>(); ArrayList<Menhir> temp = new ArrayList<Menhir>(); for(int i = 0; i < menhirs.size(); i++){ temp.add(menhirs.get(i)); } while(temp.size() > 0) { int minIndex = 0; for(int i = 0; i < temp.size(); i++) { if(temp.get(i).y < temp.get(minIndex).y) { minIndex = i; } } sorted.add(temp.get(minIndex)); temp.remove(minIndex); }   return sorted; }   //finds the relative angle of the mouse, and uses that to find //the angle that each menhir should hold, then draws them in place void draw(){ background(255); float dx = float(mouseX -(width/2)); float dy = float(mouseY -(height/2)); float mrads = atan(dy/dx); float diff = TWO_PI/float(menhirs.size()+1);   for (int i = 0; i< menhirs.size(); i++) { Menhir menhir = menhirs.get(i); float ang = mrads + diff*(i+1); menhir.update(ang); }     ArrayList<Menhir> tempMenhirs = zjrispolsort(menhirs);   //shadows rendered seperately so that all menhirs appear in front //of the other menhirs' shadows for (int i = 0; i< tempMenhirs.size(); i++) { Menhir menhir = tempMenhirs.get(i); menhir.displayShadow(); }   for (int i = 0; i< tempMenhirs.size(); i++) { Menhir menhir = tempMenhirs.get(i); menhir.display(); } }   // left click adds a menhir up to 10, right click removes a menhir // down to 1 void mousePressed() { if (mouseButton == LEFT && menhirs.size() < 10){ println("menhir added"); menhirs.add(new Menhir()); } else if (mouseButton == RIGHT && menhirs.size() > 1){ menhirs.remove(0); } }```

# Alex Ten Liner

For this project, I wanted 10 lines to vibrate around the courser. Several challenges that arose were trying to figure out how to make diagonal lines starting at the bottom left and moving to the top right. I still have not figured out how to make the random variable move on the inverted axis. Therefore, unlike thee other lines that run diagonal from top left to bottom right, horizontal and vertical, the diagonal lines that run from bottom left top top right do not vibrate into each other.

```void setup() {
size(400,400);
frameRate(10);
}

void draw(){
background(0);

float dx=random (-10, 10);
float dy=random (-12, 12);
float da=random (-15,15);
float db=random (-17,17);
float dc=random (-20,20);
strokeWeight(3);

//diagonal L to R down
stroke(50);
line(0,0, (mouseX-6)+dx,(mouseY-6)+dx);
stroke(150);
line((mouseX+6)+db,(mouseY+6)+db, width,height);

//horizontal
stroke(75);
line(0,height/2, (mouseX-10)+da,(mouseY));
stroke(175);
line((mouseX+10)+dc,(mouseY), width,height/2);

//vertical
stroke(255);
line(width/2,0, (mouseX),(mouseY-10)+dy);
stroke(125);
line((mouseX),(mouseY+10)+dc, width/2,height);

//diagonal L to R up top
stroke(50);
line(0,350, (mouseX-8)+db,(mouseY+5)+db);
stroke(225);
line((mouseX+5)+dy,(mouseY-8)+dy, 350,0);

//diagonal L to R up btm
stroke(100);
line(50,height, (mouseX-5)+dc,(mouseY+8)+dc);
stroke(200);
line((mouseX+8)+da,(mouseY-5)+da, width,50);
}
```

# 10 kinked lines

Moving the mouse right, the line kinks and folds downward.

```  void setup () { size (600,400); smooth (); }   void draw () {   background (100); strokeWeight (3); stroke (255);   for (int i= 140; i <400; i+=25) {   float mx = map (mouseX, 0, height, 150, 300); line (i, mx, i+40, 300);   if (mouseY>150){ for (int j=140; j<400; j+=25)   line (j, mx, j+40, 150); } }   }```

# Ten Lines

Again, for this piece I had envisioned something that played with the idea of the mouse pushing a line forward and back. For my ten lines project I had similar problems as seen in my first one. Mainly these problems dealt with if statements and making sure they weren’t contradicting one another. I created a series of ten lines that when up horizontally that reacted to whether or not the mouse was in a certain range. The lines would then move away the mouse if it was in that range. Overall I didn’t really like this piece, mostly because of the fact that it wasn’t what I envisioned in addition to my long hours spent attempting to tackle it.

```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 float x1=100; float x2=345;   int y2=300; void setup(){ size(450,450);     }     void draw(){ background(0);   stroke(255);       for (int i = 0; i < =10; i = i+1) {   float imov= map(i,0,10,0,height); line(x1, imov, x2, imov);   if( (mouseX>=200)&&(mouseX< =300)){ x1= imov-15;   }else{   x1=100; } if (mouseY<200){ x1= random(100); } }   }```