Wednesday, 28 March 2012

ON THE WAY STARTING OFF

I tried the code in lecture files to play around with mouse and create some cool effects.
CODE :
---------------------------------------------------------------------------------------------------------------
import math

def setup():
    size(600, 600)
    background(255)
    stroke(0)
    smooth()
   
def draw():
    for i in range (500):
        angle = mouseX * i
        x = i * 6.28 * math.cos(angle)
        y = i * 6.28 * math.sin(angle)
        width = 1
        rect(300+x, 300+y, width+i, width+i)
---------------------------------------------------------------------------------------------------------------
Comment :  the changes and movements are based on the mouse's X-coordinate
The result is impressive, provided 3D look.

From that, I tried to create my own one, still based on mouse's X-coordinate
CODE :
---------------------------------------------------------------------------------------------------------------
import math

def setup():
    size(600,600)
    background(255)
    stroke(0)
    smooth()

def Xfunction(z):
    return 300.*math.cos(1.6180339887*z)
   
def Yfunction(z):
    return 300.*math.sin(3.14*z)
   
   
def draw():
    background(255)
    lx = Xfunction(0.) + 300
    ly = Yfunction(0.) + 300
    for i in range(1, 600.):
        z = i / 10.
        angle = mouseX*i
        x = Xfunction(z) + angle
        y = Yfunction(z) + angle
         line(lx, ly, x, y)
        line(ly, lx, y, x)
        lx = x
        ly = y
---------------------------------------------------------------------------------------------------------------
Comment : The result is unexpected but still my first shot. Also I applied a golden ratio here.

Again, I tried something newer
Comment : I tried bigger sketch (1200x1200), also tried something deal with the mouse's Y-coordinate( here it changed the frequency of the lines appear in the sketch)
The outcome is magnificent, in fluid-form, flexible.

 CODE :
---------------------------------------------------------------------------------------------------------------
import math
   
def setup():
    size(1200,1200)
    background(255)
    stroke(0)
    smooth()

def Xfunction(z):
    return 300.*math.cos(1.6180339887*z)
   
def Yfunction(z):
    return 300.*math.sin(6.28*z)
   
   
def draw():
    background(255)
    for i in range(1, 1200.):
        z = i / 200.
        angle = mouseX*i*0.01
        trans = mouseY+i%5
        lx = Xfunction(0.) + trans
        ly = Yfunction(0.) + trans
        x = Xfunction(z) + angle
        y = Yfunction(z) + angle
         line(lx, ly, x, y)
        line(ly, lx, y, x)
        lx = x
        ly = y
---------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment