Simple Canvas example

Based on the Book "Keys to Infinity" - Clifford A. Pickover
This program compute the endpoint position (x,y) and (x2,y2) of each straight web chord of a circle.
Play with different parameters and see the results!

       
         

/*
    Functions:
    F1 - Ranunculoid :  a = 6;   b = 6;
    F2 - Cardioid    :  a = 2;   b = 2;
    F3 - Nephroid    :  a = 3;   b = 3;
    F4 - Fishtailoid :  a = 2;   b = 3;
    F5 - Amazingoid  :  a = 100; b = 100;
*/
    // params: a, b, c
for (i = 0; i <= 360; i = i + paramC) {
    theta = i * pi / 180.0;
    x = r * Math.cos(theta);
    y = r * Math.sin(theta);
    /* Select another point on circle */
    x2 = r * Math.cos(a * theta);
    y2 = r * Math.sin(b * theta);
    /* Print endpoints of each line */
    x = (x * ex + dx);
    y = (y * ey + dy);
    x2 = (x2 * ex + dx);
    y2 = (y2 * ey + dy);

    drawline(x, y, x2, y2, cor);
}