header

 

More links

AutoHotkey | Android | Arduino | COMM140Fractals | Grammar Checkers | Knots | A Million Dots Activity |  Processing | Processing for Scratch Users | Redbubble | Tutorials | Weather | World Time Meeting Planner | Favicon Generator.

Home > Tutorials > Processing > Processing Examples > Lissajous v37

Lissajous v37

Lissajous a=1 b=3

See http://en.wikipedia.org/wiki/Lissajous_curve

Lissajous Code

processing code

// Created with "Processing":http://processing.org/
// Draws a Lissajous figures
// 2 April 2011
// http://www.rupert.id.au/tutorials/processing/examples.php

int screen_width = 606;
int screen_height = 625;

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

float a = 1;
float b = 3;
float x1;
float y1;
float x2;
float y2;

int counter = 0;
int saveCounter = 0;
String file_name;

void setup(){
  smooth();
  fill(255);
  strokeWeight(1);   
  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 them
  x1 = (sin(a * counter) * AX) + screen_width / 2;
  y1 = (sin(b * counter) * BX) + screen_height / 2;
  
  counter = counter + 1;
  x2 = (sin(a * counter) * AX) + screen_width / 2;
  y2 = (sin(b * counter) * BX) + screen_height / 2;
   
  line(x1,y1,x2,y2);
    
  saveCounter = saveCounter + 1;
  if (saveCounter == 365) {
    String file_name = "Lissajou_a=" + str(a) + "_b=" + str(b);
    save(file_name);
    noLoop();
  }
}
code formatter

 

code formatter

 


APA citation:
Russell, R. (2016, July 05, 07:47 am). Lissajous v37.
     Retrieved November 22, 2024, from http://www.rupert.id.au/tutorials/processing/examples/Lissajous/lissajou_v37.php

Last refreshed: November 22 2024. 10:10.55 am

rupert dot russell at acu dot edu dot au Support Wikipedia

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.


4907 visits since April 2, 2011