INTERNET ART: networks, performative programming, and web as context


Leave a comment

Counting is fun

int xPos=200;
float w = 300;
float h = 150;
String n = “No, it’s really not!”;
float textX = 0;
float textY = h/2;
float textS = 10;
float textH = 15;
float speed = 4;

Button on_button;
int clk = 1;

void setup() {
size (300, 300);
smooth();

}

void draw() {

on_button = new Button(“Counting is Fun!”, 20, 20, 100, 50);

if (on_button.MouseIsOver()) {
rect(200, 20, 50, 50);
background(100,0,0);
}
else {
background(0,100,100);
}
if(mouseX < width/3){
background(30,100,120);
}
else if(mouseX > width/3 && mouseX < 2*(width/3)){
background(0,200,0);
}
else{
background(0,0,255);
}
line(width/3,0, width/3,height);
line(2*(width/3),0, 2*(width/3), height);

float r = random(255);
float g = random(255);
float b = random(255);
color random = color(r,g,b);
fill(random);
textSize(textH);
text(n, textX, textY);

textX=textX + speed;

if (textX > width || textX < 0){
speed = speed * -1;
}
else if (xPos >width+20){
xPos=-20;
}
on_button.Draw();
}
// mouse button clicked
void mousePressed()
{
if (on_button.MouseIsOver()) {
background(200,0,200);
frameRate(25);

float r = random(255);
float g = random(255);
float b = random(255);
color random = color(r,g,b);
fill(random);
strokeWeight(7);

ellipse(xPos, 200, 40, 40);
xPos=xPos+1;
ellipse(xPos, 100, 40, 40);
xPos=xPos+1;
line(width/2,0,width/2,height);
line(0,height/2, width, height/2);
print(“Clicked: “);
println(clk++);
}
}
class Button {
String label; // button label
float x; // top left corner x position
float y; // top left corner y position
float w; // width of button
float h; // height of button
Button(String labelB, float xpos, float ypos, float widthB, float heightB) {
label = labelB;
x = xpos;
y = ypos;
w = widthB;
h = heightB;
}

void Draw() {
fill(218);
stroke(141);
rect(x, y, w, h, 10);
textAlign(CENTER, CENTER);
fill(0);
text(label, x + (w / 2), y + (h / 2));
}

boolean MouseIsOver() {
if (mouseX > x && mouseX < (x + w) && mouseY > y && mouseY < (y + h)) {
return true;
}
return false;
}
}

Advertisements


Leave a comment

Bouncing Box

Screen Shot 2016-09-29 at 10.54.14 AM.png

boolean square = false;
float xx = random(300);
float yy = random(300);
float xx2 = random(300);

float dd = 20;
float speed = random(-2,5);
float speed2 = random(-2,5);
//color aa = #012279;
float xdirection = random (-2, 5);
float ydirection = random (-2, 5);
int xdirection2 = -2;
int ydirection2 = -2;

void setup () {
size (300,300);
background (90);
}

void draw () {
background (90);
//ellipse(xx,yy,dd,dd);
rect (xx,yy,dd,dd);

xx = xx + (speed * xdirection);
yy = yy + (speed2 * ydirection);

if (xx >width-20 || xx < 0) {
xdirection *= -1;
float rr = random(255);
float gg = random(255);
float bb = random(255);
float tt = random(255);
color ran = color(rr,gg,bb,tt);
float xdirection = random (-2, 5);

fill(ran); }
if (yy >height-20 || yy < 0) {
ydirection *= -1;
float rr = random(255);
float gg = random(255);
float bb = random(255);
float tt = random(255);
color ran = color(rr,gg,bb,tt);

float ydirection = random (-2, 5);
fill(ran);
}
}