xxxxxxxxxx
199
// Sand Stroke
// j.tarbell January, 2004
// Albuquerque, New Mexico
// complexification.net
let dim = 500;
let k = 22;
let num = 0;
let maxnum = k+1;
let time;
let ticks = 1;
let frms = 13;
//Sweep[] sweeps;
let sweeps= [];
let maxpal = 256;
let numpal = 0;
//color[] goodcolor = new color[maxpal];
let colors = '03071e-370617-6a040f-9d0208-d00000-dc2f02-e85d04-f48c06-faa307-ffba08'
function setup() {
createCanvas(500,500);
colorMode(RGB,255);
//color
//takecolor("longcolor.gif");
background(255);
// sweeps = new Sweep[maxnum];
//sweeps.push(new Sweep[maxnum]);
g=int(dim/k);
for (let y=0;y<k;y++) {
sweeps[num] = new Sweep(0,random(dim),g*10);
num++;
}
}
function getColors () {
return colors.split('-').map(c => color('#' + c))
}
function again() {
//background(0);
time++;
for (let n=0;n<num;n++) {
sweeps[n].render();
}
}
class Sweep {
constructor(X,Y,Gage){
// feet
let x;
let y;
let gage;
this.ox = x = X;
this.oy = y = Y;
this.ogage = gage = Gage;
//selfinit();
// float x, y;
// float vx;
// float ogage;
// float gage;
// color myc;
// float time;
// float sc, sg;
}
// Sweep() {
// // init
// ox = x = X;
// oy = y = Y;
// ogage = gage = Gage;
// // randomize limb properties
// selfinit();
// }
selfinit() {
// init color sweeps
myc = somecolor();
sg = random(0.01,0.1);
x = ox;
y = oy;
gage = ogage;
vx = 1.0;
}
render() {
// move through time
x+=vx;
if (x>dim)
selfinit();
tpoint(int(x),int(y),myc,0.07);
sg+=random(-0.042,0.042);
if (sg<-0.3) {
sg=-0.3;
} else if (sg>0.3) {
sg=0.3;
} else if ((sg>-0.01) && (sg<0.01)) {
if (random(10000)>9900) myc = somecolor();
}
let wd = 200;
let w = sg/wd;
for (let i=0;i<wd;i++) {
tpoint(int(x),int(y + gage*sin(i*w)),myc,0.1-i/(wd*10+10));
tpoint(int(x),int(y - gage*sin(i*w)),myc,0.1-i/(wd*10+10));
}
}
}
// color somecolor() {
// // pick some random good color
// return goodcolor[int(random(numpal))];
// }
// void takecolor(String fn) {
// BImage b;
// b = loadImage(fn);
// image(b,0,0);
// for (int x=0;x<b.width;x++){
// for (int y=0;y<b.height;y++) {
// color c = get(x,y);
// boolean exists = false;
// for (int n=0;n<numpal;n++) {
// if (c==goodcolor[n]) {
// exists = true;
// break;
// }
// }
// if (!exists) {
// // add color to pal
// if (numpal<maxpal) {
// goodcolor[numpal] = c;
// numpal++;
// } else {
// break;
// }
// }
// }
// }
// // pad with whites
// for (int k=0;k<6;k++) {
// goodcolor[numpal] = #FFFFFF;
// numpal++;
// }
// // pad with blacks
// for (int k=0;k<6;k++) {
// goodcolor[numpal] = #000000;
// numpal++;
// }
//}
// translucent point
function tpoint() {
// let r, g, b;
// let c;
c = get(x1, y1);
this.c = random(getColors())
// r = let(red(c) + (red(myc) - red(c)) * a);
// g = let(green(c) +(green(myc) - green(c)) * a);
// b = int(blue(c) + (blue(myc) - blue(c)) * a);
// let = color(r, g, b);
stroke(c);
point(x1,y1);
}
// Sand Stroke
// j.tarbell January, 2004
// function setup() {
// createCanvas(400, 400);
// }
// function draw() {
// background(220);
// }