xxxxxxxxxx
// shadow, HTML5, irregular, cyclic quadrilateral, random, sin, cos, vertex, monochrome.
// Mouse click for new shapes.
float xCtr, yCtr;
int rad, numShapes;
void setup() {
size(600, 600);
background(240);
noLoop();
}
void draw() {
numShapes = int(random(1, 100));
//call to HTML5 canvas API
externals.context.shadowOffsetX = 5;
externals.context.shadowOffsetY = 5;
externals.context.shadowBlur = 15;
externals.context.shadowColor = "black";
rect(30, 30, width-60, height-60);
for (int i = 0; i < numShapes; i++) {
rad = int(random(50, 200));
xCtr = random(rad, width - rad);
yCtr = random(rad, height - rad);
if (random(1) < 0.6) drawIrregQuad(xCtr, yCtr, rad);
else ellipse(xCtr, yCtr, rad, rad);
}
}
// based on a cyclic quadrilateral
void drawIrregQuad(float xIn, float yIn, int sze) {
//strokeWeight(0.5);
noStroke();
int strtAng = int(random(5, 85));
int a = strtAng;
beginShape();
for (int i = 0; i <= 3; i++) {
if (i == 1) a += (90 - strtAng) * 2 + int(random(-5, 5));
else if (i == 2) a += 180 - (2 *(90 - strtAng))+ int(random(-5, 5));
else if (i == 3) a += 2 * (90 - strtAng)+ int(random(-5, 5));
float x = xIn + cos(radians(a)) * sze;
float y = yIn + sin(radians(a)) * sze;
vertex(x, y);
}
endShape(CLOSE);
}
void mousePressed() {
background(240);
redraw();
}