66 * 4. Morphs it into the Makeability Lab Logo
77 */
88
9+ // In the future, we could consider:
10+ // 4th of July — star shape (5-pointed), red/white/blue
11+ // 🦃 Thanksgiving (Nov) — turkey? Might be tough at this resolution. A fall leaf could work better — maple leaf shape in red/orange/yellow
12+ // ⭐ New Year's — star or firework burst
13+ // 🌸 Spring/Cherry Blossom — simple flower shape, pink (could double for UW cherry blossom season)
914
1015import {
1116 MakeabilityLabLogo , Grid , Triangle , ORIGINAL_COLOR_ARRAY ,
@@ -28,6 +33,7 @@ let mouseX = 0;
2833let makeLabLogoStatic = null ;
2934let currentTriangleArt = null ;
3035let makeLabGrid = null ;
36+ let currentLerpAmt = 0 ;
3137
3238// The Morph Data
3339let animatedTriangles = [ ] ;
@@ -108,6 +114,7 @@ function setupCanvas(artData) {
108114
109115 makeLabLogoStatic = new MakeabilityLabLogo ( logoX , logoY , TRIANGLE_SIZE ) ;
110116 makeLabLogoStatic . visible = false ;
117+ makeLabLogoStatic . isLabelVisible = true ;
111118
112119 // Re-map the triangles for the new layout
113120 createAnimationMapping ( ) ;
@@ -168,38 +175,47 @@ function createAnimationMapping() {
168175function updateAnimation ( ) {
169176 const smallBuffer = WIDTH_MARGIN_PCT * logicalWidth ;
170177 const effectiveWidth = logicalWidth - 2 * smallBuffer ;
171-
172- // Calculate morph progress (0.0 to 1.0) based on Mouse X
173- const lerpAmt = map ( mouseX , smallBuffer , effectiveWidth , 0 , 1 , true ) ;
178+ currentLerpAmt = map ( mouseX , smallBuffer , effectiveWidth , 0 , 1 , true ) ;
174179
175180 for ( const tri of animatedTriangles ) {
176- tri . x = lerp ( tri . _originState . x , tri . _destState . x , lerpAmt ) ;
177- tri . y = lerp ( tri . _originState . y , tri . _destState . y , lerpAmt ) ;
178- tri . fillColor = lerpColor ( tri . _originState . fill , tri . _destState . fill , lerpAmt ) ;
179- tri . strokeColor = lerpColor ( tri . _originState . stroke , tri . _destState . stroke , lerpAmt ) ;
181+ tri . x = lerp ( tri . _originState . x , tri . _destState . x , currentLerpAmt ) ;
182+ tri . y = lerp ( tri . _originState . y , tri . _destState . y , currentLerpAmt ) ;
183+ tri . fillColor = lerpColor ( tri . _originState . fill , tri . _destState . fill , currentLerpAmt ) ;
184+ tri . strokeColor = lerpColor ( tri . _originState . stroke , tri . _destState . stroke , currentLerpAmt ) ;
180185 }
181186}
182187
183188function drawLoop ( ) {
184- // Clear Screen
189+ // Clear screen first
185190 ctx . fillStyle = 'rgb(250, 250, 250)' ;
186191 ctx . fillRect ( 0 , 0 , logicalWidth , logicalHeight ) ;
187192
188- updateAnimation ( ) ;
193+ updateAnimation ( ) ; // sets currentLerpAmt
189194
190195 if ( makeLabGrid && makeLabGrid . visible ) makeLabGrid . draw ( ctx ) ;
191-
192- // Draw the animated morphing triangles
193- for ( const tri of animatedTriangles ) {
194- tri . draw ( ctx ) ;
195- }
196196
197- // Draw Logo Overlay (Debugging: press 'h' to toggle)
197+ for ( const tri of animatedTriangles ) tri . draw ( ctx ) ;
198+
198199 if ( makeLabLogoStatic && makeLabLogoStatic . visible ) makeLabLogoStatic . draw ( ctx ) ;
199200
201+ // Labels: art message fades out, logo label fades in
202+ if ( currentTriangleArt ?. message ) currentTriangleArt . drawMessage ( ctx , 1 - currentLerpAmt ) ;
203+ drawLogoLabel ( ctx , currentLerpAmt ) ;
204+
200205 requestAnimationFrame ( drawLoop ) ;
201206}
202207
208+ const LABEL_APPEAR_THRESHOLD = 0.7 ;
209+ const LABEL_SLIDE_FRACTION = 0.4 ;
210+
211+ function drawLogoLabel ( ctx , lerpAmt ) {
212+ if ( lerpAmt <= LABEL_APPEAR_THRESHOLD ) return ;
213+ const progress = ( lerpAmt - LABEL_APPEAR_THRESHOLD ) / ( 1 - LABEL_APPEAR_THRESHOLD ) ;
214+ const eased = progress * progress * ( 3 - 2 * progress ) ; // smoothstep
215+ const slideOffset = makeLabLogoStatic . labelFontSize * LABEL_SLIDE_FRACTION * ( 1 - eased ) ;
216+ makeLabLogoStatic . drawLabel ( ctx , { opacity : eased , yOffset : slideOffset } ) ;
217+ }
218+
203219// --- Inputs ---
204220function onMouseMove ( e ) {
205221 const rect = canvas . getBoundingClientRect ( ) ;
0 commit comments