Skip to content

Commit 3c4a8fb

Browse files
committed
John Glacier Backdrop updates
1 parent c53b945 commit 3c4a8fb

File tree

11 files changed

+85
-94
lines changed

11 files changed

+85
-94
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Projects/.DS_Store

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
6 KB
Binary file not shown.
115 KB
Binary file not shown.
89.1 KB
Binary file not shown.

Projects/John-Glacier-Backdrop/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
<link rel="stylesheet" type="text/css" href="style.css">
1111

12-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.3/p5.min.js"
13-
integrity="sha512-I0Pwwz3PPNQkWes+rcSoQqikKFfRmTfGQrcNzZbm8ALaUyJuFdyRinl805shE8xT6iEWsWgvRxdXb3yhQNXKoA=="
14-
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
12+
<script src="libraries/p5.min.js"></script>
1513
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.3/addons/p5.sound.js"
1614
integrity="sha512-TU9AWtV5uUZPX8dbBAH8NQF1tSdigPRRT82vllAQ1Ke28puiqLA6ZVKxtUGlgrH6yWFnkKy+sE6luNEGH9ar0A=="
1715
crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Projects/John-Glacier-Backdrop/libraries/p5.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/John-Glacier-Backdrop/sketch.js

Lines changed: 69 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2,137 +2,116 @@ let green, purpleFlower, redFlower, butterfly;
22
let font;
33
let points = [];
44
let choice = 0;
5-
let gridSize = 90;
5+
let gridSize = 120;
66
let mic, fft;
77
let amplitude = 0;
88
let smoothAmp = 0;
99
let bassAmp = 0;
1010
let trebleAmp = 0;
11-
let sampleFactor;
12-
let colorShift;
11+
let images = [];
1312

1413
function preload() {
15-
green = loadImage("https://res.cloudinary.com/din8rv70n/image/upload/v1743678123/green_j4iti0.png");
16-
purpleFlower = loadImage("https://res.cloudinary.com/din8rv70n/image/upload/v1743678122/purple_flower_yhbem7.png");
17-
redFlower = loadImage("https://res.cloudinary.com/din8rv70n/image/upload/v1743678124/red_flower_xl2h6r.png");
18-
butterfly = loadImage("https://res.cloudinary.com/din8rv70n/image/upload/v1743678118/butterfly_yr5u6w.png");
14+
green = loadImage("Assets/green.png");
15+
purpleFlower = loadImage("Assets/purple flower.png");
16+
redFlower = loadImage("Assets/red flower.png");
17+
butterfly = loadImage("Assets/butterfly.png");
1918

20-
font = loadFont("https://res.cloudinary.com/din8rv70n/raw/upload/v1743678117/camera_ett6ql.ttf"); // Replace with your font file
19+
font = loadFont("Assets/camera.ttf");
20+
21+
images = [green, purpleFlower, redFlower, butterfly];
2122
}
2223

2324
function setup() {
24-
createCanvas(1920, 1200);
25-
imageMode(CENTER);
25+
createCanvas(1536,896);
26+
imageMode(CORNER);
27+
28+
points = font.textToPoints("JOHN", width/2 - 380, height / 2 - 50, 250, {
29+
sampleFactor: 0.07,
30+
simplifyThreshold: 0,
31+
});
2632

27-
points = font.textToPoints("JOHN GLACIER", 35, height / 2, 240, {
28-
sampleFactor: sampleFactor, // Keep density the same
33+
let additionalPoints = font.textToPoints("GLACIER", 170, height / 2 + 180, 250, {
34+
sampleFactor: 0.07,
2935
simplifyThreshold: 0,
3036
});
3137

38+
points = points.concat(additionalPoints);
39+
40+
41+
42+
3243
mic = new p5.AudioIn();
3344
mic.start();
3445

3546
fft = new p5.FFT();
3647
fft.setInput(mic);
48+
49+
frameCount = 0;
3750
}
3851

3952
function draw() {
4053
fft.analyze();
4154
let bass = fft.getEnergy("bass");
4255
let mid = fft.getEnergy("mid");
4356
let treble = fft.getEnergy("treble");
57+
58+
amplitude = (bass * 0.6 + mid * 0.3 + treble * 0.1) * 0.02;
59+
smoothAmp = lerp(smoothAmp, amplitude, 0.1);
60+
bassAmp = lerp(bassAmp, bass * 0.01, 0.1);
61+
trebleAmp = lerp(trebleAmp, treble * 0.01, 0.1);
62+
63+
background(0);
64+
65+
//rectangle guidelines for layout
66+
// fill(100);
67+
// rectMode(CENTER);
68+
// rect(width/2,50,10,height*2);
69+
// rect(width/2,height/2,width,10);
4470

45-
amplitude = (bass * 0.6 + mid * 0.3 + treble * 0.1) * 0.015; // Weighted response
46-
smoothAmp = lerp(smoothAmp, amplitude, 0.1); // Smooth transition
47-
sampleFactor = map(bass,0,255,0.1,2);
48-
bassAmp = lerp(bassAmp, bass * 0.01, 0.1); // Separate bass tracking
49-
trebleAmp = lerp(trebleAmp, treble * 0.01, 0.1); // Separate treble tracking
71+
nameAnimation(smoothAmp, bassAmp, trebleAmp);
72+
5073

5174

52-
if (choice === 0) {
53-
nameAnimation(smoothAmp, bassAmp, trebleAmp);
54-
55-
} else if (choice === 1) {
56-
// flowerSwipe(smoothAmp);
57-
flowerSwipe(smoothAmp);
58-
}
59-
}
6075

6176
function nameAnimation(bass, treble, mid) {
62-
// background("#f3d333",10);
63-
background(0);
64-
65-
77+
noStroke();
78+
let t = frameCount * 0.03;
79+
let baseRadius = 100 * 100;
80+
let numCopies = 50;
81+
let angleStep = TWO_PI / numCopies;
82+
let xOffset = (t * 250) % width;
83+
let yOffset = height / 1.35 + bass * 50;
6684

6785
for (let i = 0; i < points.length; i++) {
6886
let p = points[i];
69-
70-
// Size pulsing effect from bass
71-
let size = map(sin(frameCount * 0.02 + i * 0.05) * bass, -1, 1, 15, 25);
72-
73-
// Letter shaking effect from treble
74-
let shakeX = map(noise(frameCount * 0.01 + i * 0.05), 0, 1, -treble * 0.2, treble * 0.2);
75-
let shakeY = map(noise(frameCount * 0.02 + i * 0.05), 0, 1, -treble * 0.2, treble * 0.2);
76-
77-
// Rotation effect from mid frequencies
78-
let rotation = map(sin(frameCount * 0.02 + i * 0.01) * mid, -1, 1, -PI / 4, PI / 4);
79-
80-
push();
81-
noStroke();
82-
let t = frameCount * treble / 50; // Time-based variable for smooth color change
83-
let r = map(sin(t + i * 0.1), -1, 1, 200, 255);
84-
let g = map(sin(t + i * 0.2), -1, 1, 50, 150);
85-
let b = map(sin(t + i * 0.3), -1, 1, 100, 200);
86-
87-
// fillGradient('radial', {
88-
// from: [p.x, p.y, size * 2], // x, y, radius
89-
// to: [p.x, p.y, size / 2], // x, y, radius
90-
// steps: [
91-
// color(100, g, 200),
92-
// color(0, 0, b),
93-
// color(r, g, b)
94-
// ] // Array of p5.color objects or arrays containing [p5.color Object, Color Stop (0 to 1)]
95-
// });
96-
fill(r,g,b);
97-
// ellipse(p.x, p.y, size / 5, size / 5);
98-
pop();
99-
100-
push();
101-
translate(p.x + shakeX, p.y + shakeY); // Apply shake effect
102-
rotate(rotation); // Apply rotation effect
103-
104-
let images = [green, purpleFlower, redFlower, butterfly];
87+
let size = map(sin(t + i * 0.1) * bass, -1, 1, 15, 40);
88+
let smoothShakeX = map(sin(t + i * 0.1), -1, 1, -treble * 0.1, treble * 0.1);
89+
let smoothShakeY = map(cos(t + i * 0.2), -1, 1, -treble * 0.1, treble * 0.1);
10590
let img = images[i % images.length];
106-
107-
image(img, 0, 0, size, size);
91+
92+
push();
93+
translate(p.x + smoothShakeX, p.y + smoothShakeY);
94+
image(img, 0, 0, size / 1.5, size / 1.5);
10895
pop();
10996
}
11097

98+
// for (let i = 0; i < numCopies; i++) {
99+
// let angle = i * angleStep;
100+
// let scaleFactor = abs(sin(angle + t) * 1.5);
101+
// let x = xOffset + cos(angle) * baseRadius;
102+
// let y = yOffset + sin(angle) * baseRadius * scaleFactor;
103+
104+
// push();
105+
// translate(x, y);
106+
// rotate(angle + t * 2);
107+
// scale(scaleFactor + 0.5);
108+
// let img = images[i % images.length];
109+
// image(img, 0, 0, 120, 120);
110+
// pop();
111+
// }
112+
}
111113
}
112114

113115

114-
function flowerSwipe() {
115-
// background(0,10);
116-
background("#f3d333");
117-
push();
118-
imageMode(CORNER);
119-
for (let x = 0; x < width; x += gridSize){
120-
for (let y = 0; y < height; y += gridSize){
121-
let images = [green, purpleFlower, redFlower, butterfly];
122-
let img1 = images[(x / gridSize + y / gridSize) % images.length];
123-
image(img1, x, y, 100, 100);
124-
125-
126-
}
127-
}
128116

129-
pop();
130-
}
131117

132-
function keyPressed() {
133-
if (key === "1") {
134-
choice = 0;
135-
} else if (key === "2") {
136-
choice = 1;
137-
}
138-
}

Projects/John-Glacier-Backdrop/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ html, body {
55

66
canvas {
77
display: block;
8+
89
}

0 commit comments

Comments
 (0)