Lissajou's or Browditch's Curve


-- Figure ou Courbe de Lissajous by GT ( Adaptation pour codea )
-- http://www.civil.usherbrooke.ca/cours/gin202/vb/vbprog3.htm

function setup()
    -- Oscilloscope
    pencolor=color(108, 255, 0, 255)
    parameter.integer("val1",0,99,99)
    parameter.integer("val2",0,99,98)
    parameter.integer("val3",0,99,90)
    parameter.integer("nline",0,1000,200)
    parameter.integer("pensize",1,10,1)
    parameter.color("pencolor",pencolor)
end

function draw()
    background(40, 40, 50) ; strokeWidth(pensize) ; stroke(pencolor)
    x0=WIDTH/2 ; y0=HEIGHT/2 ; curx=x0 ; cury=0

    for i=1, nline do
        -- val1 : multiplicateur sin : 0 à 99
        -- val2 : multiplicateur cos : 0 à 99
        -- val3 : n * pi * 10 : 0 à 99
        w = i * val3 * 0.3141592654
        x = x0 + x0 * math.sin(w * val1 * 0.01)
        y = y0 - y0 * math.cos(w * val2 * 0.01)
        line(curx,cury,x,y)
        curx=x ; cury=y
    end

end

possible improvements :

  • animation ( horizontal rotation )
  • gradient colors
  • sounds like animoog
  • 3d lissajou curve

test variables :

v1 v2 v3
99 66 26
99 66 70
99 50 70
39 61 70
22 61 30
78 61 30
88 50 30
88 50 35
24 36 29
62 31 39
62 62 48 ( Hypnotic )
it’s very fast with 1000 lines

Cool.

Any reason you are not using the math.pi function instead of 0.3141592654?

yes math.pi/10 thanks

for sounds i have the same issue than “simple piano”

Yeah - hopefully @Simeon is still looking into it