Personal tools

LissajousCurves

From OpenLaszlo

Simply compile and run this program to see how it all works:

<canvas debug="false">
    <drawview id="dv" width="200" height="200" oninit="update()">
    <method name="update">
        <![CDATA[
            this.clear()
            d2r = 2 * Math.PI / 360;
            this.beginPath();
            this.moveTo(100+100*Math.sin(0),100+100*Math.cos(0));
            for (i=1;i<360;i++) {
                this.lineTo(100+100*Math.sin(xs.value*i*d2r),
                        100+100*Math.cos(ys.value*i*d2r));
            }
            this.strokeStyle = 0x000000;
            this.stroke();
        ]]>
    </method>
    </drawview>
    <text x="0" y="210" text="${'X='+xs.value+':'}" />
    <slider value="5" id="xs" x="40" y="210" height="20" width="160"
        maxvalue="20" minvalue="1" showvalue="false" showfill="false">
        <method event="onvalue">
            dv.update();
        </method>
    </slider>
    <text x="0" y="240" text="${'Y='+ys.value+':'}" />
    <slider value="3" id="ys" x="40" y="240" height="20" width="160"
        maxvalue="20" minvalue="1" showvalue="false" showfill="false">
        <method event="onvalue">
            dv.update();
        </method>
    </slider>
</canvas>