๐Ÿ–Š๏ธ๐Ÿ‘ป Stage 7: Text Styling & Motion Trails

Experimenting with stroke, fill, and classic Superman trail effects

movieCreditsSim7.html

๐Ÿ“‹ Stage 7 Overview

Stage 7 explores two major visual enhancements inspired by the original Superman (1978) credits:

  1. Text Stroke and Fill Controls: Configure text outlines (stroke) and interior color (fill) independently
  2. Motion Trails: Create the classic "ghosting" effect where text leaves fading trails as it moves
๐Ÿงช Experimental Focus: This stage provides extensive configuration options to experiment with different visual styles. Students can explore hollow letters, outlined text, neon effects, and various trail lengths to discover what looks best!

๐Ÿ‘ค User Request #12 - Stage 7: Text Styling & Trails

Request: "In version 7, let's experiment with a stroke and fill setting on the text. Using variables let's see how things look with a stroke and thickness and no fill, or with combinations we can try with variables. Let's also try an effect where the text leaves a 'trail' in the background, as seen in the Superman credits."

Goals:

Key Techniques to Implement:

๐Ÿค– Implementation - Stroke & Fill Configuration

Added comprehensive text appearance controls:

// ============================================ // STAGE 7: TEXT APPEARANCE CONFIGURATION // ============================================ // *** TEXT STROKE (OUTLINE) SETTINGS *** // Enable or disable stroke (outline) on text const TEXT_STROKE_ENABLED = true; // Stroke width in pixels // Larger values = thicker outline const TEXT_STROKE_WIDTH = 2; // Stroke color (HSB mode) const TEXT_STROKE_HUE = 0; // 0 with sat=0 = white/gray/black const TEXT_STROKE_SATURATION = 0; // 0 = grayscale const TEXT_STROKE_BRIGHTNESS = 100; // 100 = white outline // *** TEXT FILL SETTINGS *** // Enable or disable fill (interior) on text const TEXT_FILL_ENABLED = true;
๐Ÿ“š Design Decisions:

Default Configuration:

  • Both enabled: Creates bold, outlined text that's easy to read
  • White stroke: Provides contrast against any fill color
  • Width = 2: Visible but not overpowering

Why separate enable flags?

  • Allows four distinct visual modes:
  • 1. Both ON: Bold outlined letters (classic)
  • 2. Stroke ON, Fill OFF: Hollow/outline only (neon effect)
  • 3. Stroke OFF, Fill ON: Solid letters (clean, simple)
  • 4. Both OFF: Invisible (debugging/special effects)

Why HSB color controls?

  • Matches existing color system (consistency)
  • Easy to create white (sat=0, bright=100)
  • Easy to create black (sat=0, bright=0)
  • Easy to create any color (adjust hue, keep sat=100)

๐Ÿค– Implementation - applyTextStyle() Function

Created centralized function to apply stroke/fill styling:

/** * STAGE 7: NEW FUNCTION - Applies stroke and fill styling to text * * This function centralizes all stroke/fill logic in one place, * making it easy to experiment with different text appearances. */ function applyTextStyle(hue, opacity) { // Apply stroke (outline) if enabled if (TEXT_STROKE_ENABLED) { stroke(TEXT_STROKE_HUE, TEXT_STROKE_SATURATION, TEXT_STROKE_BRIGHTNESS, opacity); strokeWeight(TEXT_STROKE_WIDTH); } else { noStroke(); } // Apply fill (interior color) if enabled if (TEXT_FILL_ENABLED) { fill(hue, 80, 100, opacity); } else { noFill(); } }
๐Ÿ“š Function Design Principles:

Why create a separate function?

  • DRY Principle: Don't Repeat Yourself - stroke/fill logic used in 4 places
  • Maintainability: Change styling logic once, affects all text
  • Consistency: Guarantees same styling everywhere
  • Experimentation: Easy to modify one place and see effects globally

Parameters:

  • hue: Base color varies per credit/title (passed in)
  • opacity: Fade effects require transparency (passed in)
  • Constants: Stroke settings stay consistent (from config)

Where called:

  1. drawNormalTitle() - Regular title rendering
  2. drawBlurredTitle() - Title with blur effect
  3. drawNormalCredit() - Regular credit rendering
  4. drawBlurredCredit() - Credit with blur effect

Opacity propagation: Function receives opacity from caller, applies to both stroke and fill. This ensures fade effects work correctly - as text fades, both outline and interior fade together!

๐Ÿค– Implementation - Motion Trail Configuration

Added controls for the classic Superman trail effect:

// ============================================ // STAGE 7: MOTION TRAIL CONFIGURATION // ============================================ // *** MOTION TRAIL SETTINGS *** // Creates the classic Superman effect where text leaves a fading trail // Enable or disable motion trails const TRAIL_ENABLED = true; // Trail fade speed (0-255) // Lower values = longer trails (slow fade) // Higher values = shorter trails (fast fade) const TRAIL_FADE_AMOUNT = 10; // Trail fade method const TRAIL_FADE_METHOD = "overlay";
๐Ÿงช Trail Length Examples:

TRAIL_FADE_AMOUNT impact:

  • 3-5: Very long trails, ghostly effect, text visible for ~1 second
  • 10: Medium trails, classic Superman look
  • 20: Short trails, subtle motion blur
  • 50: Very short trails, almost no effect
  • 100+: Nearly instant fade, similar to no trails

Recommended starting values:

  • Dramatic ghosting: 5
  • Classic Superman: 10
  • Subtle motion: 20

๐Ÿค– Implementation - Trail Rendering Technique

Created drawBackgroundWithTrails() to implement frame persistence:

/** * STAGE 7: Draws the space background with optional motion trails * * Motion trails work by NOT completely clearing the previous frame. * Instead, we draw a semi-transparent black rectangle over the canvas, * which gradually fades the old content while keeping it slightly visible. */ function drawBackgroundWithTrails() { if (TRAIL_ENABLED && TRAIL_FADE_METHOD === "overlay") { // *** TRAIL EFFECT: Semi-transparent fade *** push(); noStroke(); // Map TRAIL_FADE_AMOUNT (0-255) to alpha in HSB mode (0-100) let fadeAlpha = map(TRAIL_FADE_AMOUNT, 0, 255, 0, 100); fill(0, 0, 0, fadeAlpha); rect(0, 0, width, height); pop(); // Draw stars on top of the fading layer drawStars(); } else { // No trails - completely clear background each frame background(0, 0, 0); drawStars(); } }
๐Ÿ“š How Motion Trails Work:

Traditional Animation (No Trails):

  1. Clear entire canvas to black: background(0, 0, 0)
  2. Draw stars
  3. Draw text at new position
  4. Result: Only current frame visible, previous frames erased

Trail Effect (Frame Persistence):

  1. Draw semi-transparent black rectangle: fill(0, 0, 0, fadeAlpha)
  2. This DIMS previous frames but doesn't erase them completely
  3. Draw stars (fresh each frame)
  4. Draw text at new position
  5. Result: Current frame + fading "ghosts" of previous frames

Mathematical Explanation:

  • Frame 1: Text drawn at opacity 100
  • Frame 2: Black overlay dims Frame 1 text to ~90, new text at 100
  • Frame 3: Frame 1 text now ~80, Frame 2 text ~90, new text 100
  • Result: Multiple "ghost" copies at decreasing opacity

Why stars need special handling:

Stars are redrawn fresh each frame because they're stationary - we want them at full brightness, not fading. Text moves, so we want trails; stars don't move, so we redraw them!

๐Ÿงช Experimental Combinations to Try

Experiment 1: Hollow Neon Letters
TEXT_STROKE_ENABLED = true TEXT_STROKE_WIDTH = 2 TEXT_STROKE_HUE = 180 // Cyan TEXT_STROKE_SATURATION = 100 // Full color TEXT_STROKE_BRIGHTNESS = 100 TEXT_FILL_ENABLED = false // KEY: No fill! TRAIL_ENABLED = true TRAIL_FADE_AMOUNT = 5 // Long trails

Effect: Hollow cyan letters with long glowing trails - like neon signs in space!

Experiment 2: Comic Book Style
TEXT_STROKE_ENABLED = true TEXT_STROKE_WIDTH = 3 // Thick outline TEXT_STROKE_HUE = 0 TEXT_STROKE_SATURATION = 0 TEXT_STROKE_BRIGHTNESS = 0 // Black outline TEXT_FILL_ENABLED = true // Colored fill TRAIL_ENABLED = false // No trails

Effect: Bold colored letters with thick black outlines - classic comic book text!

Experiment 3: Ghost Mode
TEXT_STROKE_ENABLED = false TEXT_FILL_ENABLED = true TRAIL_ENABLED = true TRAIL_FADE_AMOUNT = 3 // KEY: Very long trails!

Effect: Solid letters with extremely long fading trails - ethereal ghost effect!

Experiment 4: Strobe Effect
TEXT_STROKE_ENABLED = true TEXT_STROKE_WIDTH = 1 TEXT_STROKE_BRIGHTNESS = 100 // White outline TEXT_FILL_ENABLED = true TRAIL_ENABLED = true TRAIL_FADE_AMOUNT = 50 // KEY: Very fast fade!

Effect: Outlined letters with barely visible trails - crisp, modern look with subtle motion!

Experiment 5: Authentic Superman
TEXT_STROKE_ENABLED = false // Original had no outlines TEXT_FILL_ENABLED = true TRAIL_ENABLED = true TRAIL_FADE_AMOUNT = 10 // Medium trails

Effect: Closest to original 1978 Superman credits - solid colored text with medium-length trails!

๐Ÿ”ฌ Technical Deep Dive: Stroke & Fill in p5.js

๐Ÿ“š p5.js Drawing Model:

Every shape in p5.js has two components:

  1. Stroke: The outline/border of the shape
  2. Fill: The interior area of the shape

Control functions:

  • stroke(color) - Set outline color
  • strokeWeight(width) - Set outline thickness
  • noStroke() - Disable outline
  • fill(color) - Set interior color
  • noFill() - Make interior transparent

Drawing order matters:

// CORRECT: Set style, then draw stroke(0, 0, 100); // White outline strokeWeight(2); fill(180, 80, 100); // Cyan fill text("Hello", 100, 100); // WRONG: Draw first, style after (won't work!) text("Hello", 100, 100); stroke(0, 0, 100); // Too late!

State persistence:

Style settings persist until changed:

stroke(0, 0, 100); text("A", 50, 50); // Has white stroke text("B", 100, 50); // STILL has white stroke! noStroke(); text("C", 150, 50); // Now no stroke

Why applyTextStyle() is called before each text():

Ensures correct styling is active for that specific text draw, regardless of what was set previously!

๐ŸŽ“ Learning Outcomes: Stage 7

๐Ÿ“š Computer Graphics Concepts:

1. Stroke and Fill:

  • Understanding dual-component drawing model
  • Independent control of outline and interior
  • Creating different visual effects through combinations
  • State management in graphics systems

2. Frame Persistence:

  • Traditional animation: clear frame, redraw everything
  • Trail effect: preserve previous frames with gradual fade
  • Trade-off: trails vs. performance (more layers to render)
  • Opacity as fade mechanism

3. Configuration-Driven Design:

  • Seven new configuration variables added
  • Boolean flags enable/disable features independently
  • Numeric parameters control intensity/appearance
  • Easy experimentation without code changes

4. Code Organization:

  • applyTextStyle() demonstrates function extraction
  • Centralized logic easier to maintain and modify
  • Separation of concerns: styling vs. positioning
  • Reusable code reduces duplication

๐ŸŽฌ Film History: Superman (1978) Credits

๐Ÿ“š Historical Context:

Revolutionary Technique:

  • 1978: Superman credits used innovative motion control photography
  • Text filmed moving toward camera through space
  • Long exposure + camera movement = natural motion blur/trails
  • Considered groundbreaking visual effects at the time

Technical Approach (Original Film):

  1. Physical text models built at different scales
  2. Models placed in dark space (simulated by black backdrop)
  3. Camera moved on rails toward/away from models
  4. Long exposure captured motion as blur trails
  5. Multiple passes combined for depth effect

Our Digital Recreation:

  1. Simulated "camera" view with growing/shrinking text
  2. Motion trails via frame persistence (digital equivalent of long exposure)
  3. Blur effect adds scatter (simulates photographic blur)
  4. Much easier than physical models!

Why This Matters:

  • Classic effect now achievable with ~100 lines of code
  • Understanding original technique helps recreate digitally
  • Same visual result, completely different technology
  • Students learn both film history and programming!

"You will believe a man can fly" - and you can code like a Hollywood effects artist!

๐Ÿงช Student Challenges & Experiments

๐Ÿ“š Challenge 1: The Perfect Outline

Task: Find the best stroke width for readability

  • Try TEXT_STROKE_WIDTH values from 1 to 5
  • Which width is easiest to read?
  • Does it depend on TEXT_FILL_ENABLED?
  • Does text size affect optimal stroke width?

Science: This is human factors research - how design affects perception!

๐Ÿ“š Challenge 2: Trail Length Math

Task: Calculate how long trails persist

  • Animation runs at ~60 fps
  • TRAIL_FADE_AMOUNT = 10 means alpha increases by map(10, 0, 255, 0, 100) โ‰ˆ 4 per frame
  • Text needs to fade from 100 to 0 opacity: 100 / 4 = 25 frames
  • Time visible: 25 frames รท 60 fps โ‰ˆ 0.42 seconds

Experiment: Verify by changing TRAIL_FADE_AMOUNT and timing with stopwatch!

๐Ÿ“š Challenge 3: Color Harmony

Task: Create visually pleasing stroke + fill combinations

Try these color theory principles:

  • Complementary: Stroke hue = fill hue ยฑ 180ยฐ (opposite on color wheel)
  • Analogous: Stroke hue = fill hue ยฑ 30ยฐ (neighbors on color wheel)
  • Triadic: Stroke hue = fill hue ยฑ 120ยฐ (triangle on color wheel)
  • Contrast: Dark stroke + light fill, or vice versa

Question: Which combinations work best with motion trails?

๐Ÿ“š Challenge 4: Performance Testing

Task: Measure how settings affect frame rate

// Add to draw() function to display frame rate console.log("FPS:", frameRate());

Test configurations:

  • Trails ON vs. OFF
  • Stroke ON vs. OFF
  • BLUR_STRENGTH 5 vs. 10 vs. 20
  • NUM_STARS 50 vs. 100 vs. 200

Questions: Which settings slow down the animation most? Why?

๐Ÿ“š Challenge 5: Custom Visual Mode

Task: Create your own unique style

Requirements:

  1. Choose specific values for all 7 new Stage 7 variables
  2. Name your style (e.g., "Neon Dreams", "Retro Comic", "Ghost Vision")
  3. Document why you chose each value
  4. Show to class - which style is most popular?

Bonus: Create variables for multiple preset "themes" that can be switched!

โœ… Stage 7 Complete!

๐ŸŽฌ What Makes Stage 7 Special:

Visual Flexibility:

  • Seven new configuration variables for text appearance
  • Independent stroke and fill controls
  • Motion trail system with adjustable fade speed
  • Enables dozens of different visual styles

Technical Achievement:

  • applyTextStyle() centralizes rendering logic
  • Frame persistence technique for trails
  • Proper opacity handling through all effects
  • Clean separation of configuration and implementation

Educational Value:

  • Graphics programming concepts (stroke, fill, layers)
  • Animation techniques (frame persistence, trails)
  • Film history and visual effects recreation
  • Experimentation methodology
  • Color theory application

New Variables Added:

  1. TEXT_STROKE_ENABLED - Toggle outlines
  2. TEXT_STROKE_WIDTH - Outline thickness
  3. TEXT_STROKE_HUE - Outline color (hue component)
  4. TEXT_STROKE_SATURATION - Outline color (saturation)
  5. TEXT_STROKE_BRIGHTNESS - Outline color (brightness)
  6. TEXT_FILL_ENABLED - Toggle interior color
  7. TRAIL_ENABLED - Toggle motion trails
  8. TRAIL_FADE_AMOUNT - Trail fade speed
  9. TRAIL_FADE_METHOD - Trail rendering technique

Files Created:

  • ๐Ÿ“„ movieCreditsSim7.html - Full implementation with stroke/fill/trails
  • ๐Ÿ“„ chatLog7.html - Complete documentation and experiments

๐ŸŽ‰ Stage 7 demonstrates how configuration-driven design enables endless experimentation - change a few variables and create completely different visual styles!

๐Ÿš€ What's Next?

Possible Future Enhancements:

Advanced Experiments:

The visual possibilities are endless - keep experimenting! ๐Ÿ–Š๏ธ๐Ÿ‘ปโœจ