xxxxxxxxxx
144
let count = 13;
let sqr;
let scale = 0.005;
let deleteCheck = false;
let fHeight = 900;
let star;
let d;
function setup() {
createCanvas(fHeight * 1.9, fHeight + 200);
d = pixelDensity;
wcol = ["#fefffe","#fffcf4","#fff9ea","#fff6e0","#fff3d6"];
rcol = ["#b31942", "#ff000d","#f1000a","#e30007","#d50004","#c70000"];
bcol = ["#0a3161", "#2828b9","#2223b1","#1b1da8","#14189f","#0a3161"]
sky = ["#45A9E6", "#C0EAFF"];
stripes = [];
for(i = 0; i < count; i++){
stripes[stripes.length] = new Stripe(0, i * fHeight / count + 100, stripes.length);
}
background(220);
for(i = 0; i < height; i ++){
stroke(lerpColor(color(sky[0]), color(sky[1]), map(i, 0, height, 0, 1)));
line(0, i, width, i);
}
}
function draw() {
if(stripes[0] !== undefined){
for(i = 0; i < count; i++){
stripes[i].move();
stripes[i].create();
}
if(frameCount == 4){
sqr = new Sqr(0,100);
}
if(frameCount > 5 && frameCount < 5 + fHeight * 0.76){
sqr.move();
sqr.create();
}
}
if(stripes[0] !== undefined){
if(stripes[0].pos.x > width && deleteCheck == false){
for(i = 0; i < stripes.length; i++){
stripes[i] = undefined;
deleteCheck = true;
}
}
}
if(frameCount == width + 75){
loadPixels();
star = new Star(width / 2, height / 2);
}
if(frameCount > width + 75){
loadPixels();
star.update();
// print(star.val);
// print(star.psense);
// print(star.sensor);
}
}
class Stripe{
constructor(x, y, index){
this.pos = createVector(x, y);
this.vel = createVector(1, 0);
this.index = index;
if(this.index % 2 == false){
this.col = color(rcol[0]);
}else if(this.index % 2 == true){
this.col = color(wcol[0]);
}
}
move(){
this.pos.add(this.vel);
this.vel.setHeading(map(noise(stripes[0].pos.x * scale, stripes[0].pos.y * scale), 0, 1, -1, 1));
}
create(){
stroke(this.col);
strokeWeight(2)
line(this.pos.x, this.pos.y, this.pos.x, this.pos.y + fHeight / 13);
}
}
class Sqr{
constructor(x, y, index){
this.pos = createVector(x, y);
this.vel = createVector(1, 0);
this.index = index;
this.col = color(bcol[0]);
}
move(){
this.pos.add(this.vel);
this.vel.setHeading(map(noise(this.pos.x * scale, this.pos.y * scale), 0, 1, -1, 1));
}
create(){
stroke(this.col);
strokeWeight(2);
line(this.pos.x, this.pos.y, this.pos.x, this.pos.y + fHeight / 13 * 7);
}
}
class Star{
constructor(x, y){
this.pos = createVector(x, y);
this.sp = createVector(1, 0);
this.sensor = p5.Vector.add(this.pos, this.sp);
this.psense = 4 * (d * floor(this.pos.y)) * (d * width) + 4 * (d * floor(this.pos.x));
this.val = pixels[this.psense];
}
update(){
this.sensor = p5.Vector.add(this.pos, this.sp);
this.psense = (4 * (d * floor(this.sensor.y)) * (d * width) + 4 * (d * floor(this.sensor.x)));
this.val = pixels[this.psense];
print(this.sensor);
print(this.psense);
print(this.val);
}
}