> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.UwRji1C$8IQ/rev.1358
 * 
 * authors: 
 *   Jeff Martin

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// This sketch builds on a prior work, "Modified clone of 'Skull'", created by Jeff Martin
// http://studio.sketchpad.cc/sp/pad/view/ro.9oZkNsVFbcTzT/rev.87



// This sketch builds on a prior work, "Skull", created by Jeff Martin
// http://studio.sketchpad.cc/sp/pad/view/ro.9tUy1cMRfXZlD/rev.9


class Skull {
    final int centreX;
    final int centreY;
    final int eyeSize = 1;
    int posx;
    int poy;
    
    final int top;
    final int cheek;
    final int mouth;
    final int chin;
    final int jawLeft;
    final int jawRight;
    final int headLeft;
    final int headRight;

    float scale;
    int alf = 100;
    float step = random(1, 20);

    Skull(int x, int y) {
        centreX = 0;
        centreY = 0;
        posx = x;
        posy = y;

        top = centreY - 6;
        cheek = centreY + 2;
        mouth = centreY + 4;
        chin = centreY + 6;
        jawLeft = centreX - 2;
        jawRight = centreX + 2;
        headLeft = centreX - 4;
        headRight = centreX + 4;
    }

    void drawHead() {
        beginShape();
        spot(headLeft,  top);
        spot(headLeft,  cheek);
        spot(jawLeft,   cheek);
        spot(jawLeft,   chin);
        spot(jawRight,  chin);
        spot(jawRight,  cheek);
        spot(headRight, cheek);
        spot(headRight, top);
        endShape(CLOSE);
    }

    void drawEyes() {

        fill(0,156,255, alf);

        beginShape();
        spot(jawLeft - eyeSize, centreY - eyeSize);
        spot(jawLeft - eyeSize, centreY + eyeSize);
        spot(jawLeft + eyeSize, centreY + eyeSize);
        spot(jawLeft + eyeSize, centreY - eyeSize);
        endShape(CLOSE);

        beginShape();
        spot(jawRight - eyeSize, centreY - eyeSize);
        spot(jawRight - eyeSize, centreY + eyeSize);
        spot(jawRight + eyeSize, centreY + eyeSize);
        spot(jawRight + eyeSize, centreY - eyeSize);
        endShape(CLOSE);

    }

    void drawMouth() {
        noFill();

        beginShape();
        spot(jawLeft-1, cheek + 2);
        spot(jawRight+1, cheek + 2);
        endShape();

        beginShape();
        spot(centreX, cheek + 1);
        spot(centreX, cheek + 3);
        endShape();
        beginShape();
        spot(centreX+1, cheek + 1);
        spot(centreX+1, cheek + 3);
        endShape();
        beginShape();
        spot(centreX-1, cheek + 1);
        spot(centreX-1, cheek + 3);
        endShape();
    }

    void draw() {
        scale = noise(step+=.02) * 20;
        posy = noise(step) * 300;
        posx = noise(step+100) * 300;
        alf = 200 + noise(step+500) * 55;

        stroke(0,156,255, alf);
        fill(255, alf);

        drawHead();
        drawEyes();
        drawMouth();
        drawHead();
        drawEyes();
        drawMouth();
    }

    float warp(float v) {
        return scale * v + random(7);
    }

    void spot(float x, float y) {
        vertex(posx + warp(x), posy + warp(y));    
    }

}

final Skull p1 = new Skull(110, 60);
final Skull p2 = new Skull(120, 75);

void setup() {
    size(250,250);
    frameRate(20);
    strokeWeight(2);
    smooth();
}

void draw() {

    background(50);

    p1.draw();
   // p2.draw();

}