top of page

Processing Simulation

#-----------------------  UBED IBRAHIM  ---------------------

w=400
h=400

        
        
    def display(self):
        fill(127)
        ellipse(self.x,self.y,10,10)
        
balls=[]

    balls.append(Ball(random(w),random(h),random(-10,10),random(-10,10)))

​

def setup():
    global w,h
    size(w,h)
    background(32)
    
def draw():
    background(32)
        balls[i].move()
        balls[i].display()

#-----------------------  UBED IBRAHIM  ---------------------

w=400
h=400
number_balls=10

class Ball(object):
    global w,h
    
    def __init__(self,x_,y_,vx_,vy_):
        self.x=x_
        self.y=y_
        self.vx=vx_
        self.vy=vy_
        
    def move(self):
        if self.x < 0 or self.x > w:
            self.vx *= -1
        if self.y < 0 or self.y > h:
            self.vy *= -1    
        self.x += self.vx
        self.y += self.vy
        
        
    def display(self):
        fill(127)
        ellipse(self.x,self.y,10,10)
        
balls=[]
for i in range(number_balls):
    balls.append(Ball(random(w),random(h),random(-10,10),random(-10,10)))

def setup():
    global w,h
    size(w,h)
    background(32)
    
def draw():
    background(32)
    for i in range(number_balls):
        balls[i].move()
        balls[i].display()

//--------------------------- UBED IBRAHIM -----------------------


void setup(){
size(1920,1080);
background(0);
}

void draw(){
translate(width/2, height/2);
float mag = 400;
float s = 20;
noStroke();
for (int i = 0; i < 100; i++) {
  float w = map(sin(radians(frameCount)), -1,1,-100,100);
  float wave1 = map(tan(radians(frameCount*0.8 + i + w)), -1, 1, -mag, mag);
  float wave2 = map(cos(radians(frameCount + i)), -1, 1, -mag, mag);
  float c = map(sin(radians(frameCount * 5 + i)), -1, 1, 0, 255);
  fill(c);
  rect(wave1, wave2, s, s);
}

}

bottom of page