xxxxxxxxxx
68
let ci = 3 // chest color-intensity
let h2ci = 1.5 // relative intensity hand to chest
let hr2hi = 1.025 // relative intensity heart to hand
// biorythms
let ht2rr = 12; // heat diffusion to respiration rate ratio
let bpm2rr = 4; // heartbeat to respiration rate ratio
let hPc = 4; // heat diffusion pace
function setup() {
createCanvas(400, 400);
t = 0
cc = 255 - (25.5 * ci)
hac = 255 - (25.5 * ci * h2ci)
hrc = 255 - (25.5 * ci * h2ci * hr2hi)
dx = 0.0005 * hPc
}
function draw() {
t += 0.025; // time passing
background(255);
let br = sin(t); // breathing rate
let hr = sin(t * ht2rr); // heat rate
let bpm = sin(t * bpm2rr); // heart rate
// breathing chest
if (bpm > 0.25) {
stroke(hrc)
} else {
noStroke()
}
fill(cc); // chest intensity-color
ellipse(200, 200, 350 + 10 * br, 350 + 10 * br);
translate(150, 100)
rotate(0.3)
for (let px = 0; px < 3; px++) {
for (let py = 0; py < 3; py++) {
if (px < 1 || py < 1 || px + px > 3) {// touch points
if (bpm > 0.25) {
stroke(hrc)
} else {
noStroke()
}
fill(255);
ellipse(px * 75, py * 75, 25 + br, 25 + br)
// heat diffusion
noStroke();
fill(hac, hac, hac, 100);
ellipse(px * 75, py * 75, 50 + hr, 50 + hr)
}
}
}
// heat dissipation between chest and hand
hac -= (hac - cc) * dx
cc += (hac - cc) * dx
}
function keyPressed() {
// this will download the first 5 seconds of the animation!
if (key === 's') {
saveGif('S3.gif', 10);
}
}