Shop

Get Back to School with Redbubble – Shop Here! or Win Stuff Here!

Also available as a T-Shirt

// Draws a Lissajous figures
// 4 April 2011
// http://www.rupert.id.au/tutorials/processing/ex...

float Scale = 1;
int screen_width = round(1000 * Scale);
int screen_height = round(1000 * Scale);

/* Scale image and reduce by 10 pixels to remove from edge of screen */
int AX = (screen_width/2) – round(10 * Scale);
int BX = (screen_height/2) – round(10 * Scale);

float a = 1;
float b = 1;

float x1;
float y1;
float x2;
float y2;

int counter = 0;
int saveCounter = 0;
int count = 0;

String str_count;
String file_name;

void setup(){
smooth();
fill(255);
strokeWeight(1); // Thin
size(screen_width,screen_height);
}

// Based on Microworlds LOGO code from http://www.mathcats.com/gallery/15wordcontest.html
// repeat 360 [setxy (sin(2 * repcount)) * 150 (sin(3 * repcount)) * 150]

void draw(){
fill(#000000);

// Find 2 points and draw a line between themx1 = (sin(a * counter) * AX) + screen_height / 2;y1 = (sin(b * counter) * BX) + screen_height / 2;counter = counter + 1;x2 = (sin(a * counter) * AX) + screen_height / 2;y2 = (sin(b * counter) * BX) + screen_height / 2;line(x1,y1,x2,y2);counter = counter + 1;

// ellipse((sin(a * counter) * AX) + screen_width / 2 , (sin(b * counter) * BX) + screen_height / 2, 5, 5);

saveCounter = saveCounter + 1;if (saveCounter == 720) {String file_name = “Lissajou_a=” + str(a) + “_b=” + str(b) + "_"+ str(count);saveCounter = 0;save(file_name);count = count + 1;background(#cccccc);// Loop through 10 × 10if (a < 11) {a = a+1;if (a == 11) {a = 1;b = b+1;}// Stop after 100if (b == 11){noLoop();}}println(a);println(b);println(" ");}

}

// Save tif when mouse is clicked
void mouseClicked(){
// noLoop();
String file_name = “Lissajou_VI_” + str(count);
save(file_name);
count = count + 1;
counter = counter +1;
background(#cccccc);
a = random(10);
b = random(10);
saveCounter = 0;
}

Tags

processing, lissajous, maths, linear

My current project is to maser Bzier Curves in processing

View Full Profile

Comments

  • Bunny Clarke
    Bunny Clarkeover 3 years ago

    This is gorgeous. I had no idea this what you were doing. Great work.

  • Rupert  Russell
    Rupert Russellover 3 years ago

    Thanks, I am glad you like it. I had fun creating it. I hope to be able to extend this series in some new directions soon.

  • Rupert  Russell
    Rupert Russellover 3 years ago

    Also available as a T-Shirt

  • Andrew Paranavitana
    Andrew Paranav...over 3 years ago

    Brilliant work, very dynamic design!

  • Thanks for the feature!

    – Rupert Russell

  • Maria  Moro
    Maria Moroover 3 years ago

    very cool patterns… well done

desktop tablet-landscape content-width tablet-portrait workstream-4-across phone-landscape phone-portrait