Processing Stillife
2015-08-09 [EverydaySketch]
by schrodingers
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.13/processing.min.js"></script>
<canvas></canvas>
CSS
</style> <script type="text/javascript"> window.addEventListener('load', function() {
var scripts=document.body.getElementsByTagName('script');
var canvases=document.body.getElementsByTagName('canvas');
new Processing(canvases[0], scripts[0].text);
}
, false);
// Here prevent javascript in body from throwing error </script> <style>
JavaScript
/*
title: [EverydaySketch]
date: 2015-08-09
*/
color[] spring = {
#ff6699, #ff9900, #ffcc00, #9adb1b, #00cc66, #00cccc, #00ccff, #6633cc, #ff66cc
};
color violet = color(58, 48, 66);
color yellow = color(237, 230, 35);
color cyan = color(5, 190, 255);
int x1 = width/2;
int y1 = 0;
int x2 = width;
int y2 = height;
int x3 = 0;
int y3 = height;
int depth = 6;
void setup() {
size(800, 600);
smooth(5);
noStroke();
}
void draw() {
for (int j = 0; j < spring.length; j++) {
fill(spring[j]);
sierp(x1,y1, x2,y2, x3,y3, 6);
}}
void sierp(x1,y1, x2,y2, x3,y3){
int depth = 6;
triangle(x1,y1, x2,y2, x3,y3);
if (depth == 0) {
triangle(x1,y1, x2,y2, x3,y3);
}
else {
sierp(x1,y1, x2,y2, x3,y3);
/* sierp(
(x1+x2)/2,(y1+y2)/2,
(x1+x3)/2, (y1+y3)/2,
(x2+x3)/2, (y2 + y3)/2);*/
depth-=1;
}
}