xxxxxxxxxx
116
let show = [true, true, true];
function setup() {
createCanvas(650, 700);
}
function draw() {
background(255);
let moving = -0.3;
let alt = height * 0.8;
push();
translate(0, height * 0.5);
let oldval = 0;
let val = 0;
let offset = 1000+moving*frameCount*0.03;
for (let ni = -1; ni < width; ni++) {
oldval = val;
val = noise(ni * 0.01 + offset) * 100.0;
line(ni, oldval, ni + 1, val);
}
pop();
push();
translate(0, height * 0.3);
oldval = 0;
val = 0;
offset = 2000-moving*frameCount*0.02;
for (let ni = -1; ni < width; ni++) {
oldval = val;
val = noise(ni * 0.01 + offset) * 100.0;
line(ni, oldval, ni + 1, val);
}
pop();
push();
translate(0, height * 0.7);
oldval = 0;
val = 0;
offset = 3000+moving*frameCount*0.01;
for (let ni = -1; ni < width; ni++) {
oldval = val;
val = noise(ni * 0.01 + offset) * 100.0;
line(ni, oldval, ni + 1, val);
}
pop();
push();
translate(width / 2, height * 0.9);
// Pupil
stroke(0);
strokeWeight(1.2);
fill(220);
ellipse(0, 0, width * 0.5, height * 0.05);
let theta = -16 * PI / 180;
if (show[0]) {
// GS 1
strokeWeight(1.2);
stroke(255, 0, 0);
line(-width / 4, 0, -width / 4 + alt * sin(theta), -alt);
line(width / 4, 0, width / 4 + alt * sin(theta), -alt);
strokeWeight(0.5);
line(0, 0, alt * sin(theta), -alt);
noStroke();
fill(255, 0, 0, 20);
rhombus(theta, alt, width / 2);
fill(255, 0, 0);
text("Guide Star 1",-40+alt*sin(theta),-alt-10)
}
if (show[1]) {
// GS 2
theta = -theta;
strokeWeight(1.2);
stroke(255, 0, 0);
line(-width / 4, 0, -width / 4 + alt * sin(theta), -alt);
line(width / 4, 0, width / 4 + alt * sin(theta), -alt);
strokeWeight(0.5);
line(0, 0, alt * sin(theta), -alt);
noStroke();
fill(255, 0, 0, 20);
rhombus(theta, alt, width / 2);
fill(255, 0, 0);
text("Guide Star 2",-30+alt*sin(theta),-alt-10)
}
if (show[2]) {
// Target
theta = 0;
strokeWeight(1.2);
stroke(0, 0, 255);
line(-width / 4, 0, -width / 4 + alt * sin(theta), -alt);
line(width / 4, 0, width / 4 + alt * sin(theta), -alt);
strokeWeight(0.5);
line(0, 0, alt * sin(theta), -alt);
noStroke();
fill(0, 0, 255, 40);
rhombus(0, alt, width / 2);
fill(0, 0, 255);
text("Target",-20+alt*sin(theta),-alt-10)
}
pop();
}
function rhombus(angle, alt, base) {
beginShape();
vertex(-base / 2, 0);
vertex(-base / 2 + alt * sin(angle), -alt);
vertex(base / 2 + alt * sin(angle), -alt);
vertex(base / 2, 0);
endShape();
}