Overview
The wonder illustration system (lib/ui/wonder_illustrations/) provides layered, animated illustrations for each of the eight wonders. Each wonder has custom foreground, middleground, and background layers that work together to create parallax effects and immersive visuals.
Core System
WonderIllustration
Location:lib/ui/wonder_illustrations/common/wonder_illustration.dart
Convenience wrapper that routes to the correct wonder-specific illustration.
Usage:
WonderType.chichenItza→ ChichenItzaIllustrationWonderType.christRedeemer→ ChristRedeemerIllustrationWonderType.colosseum→ ColosseumIllustrationWonderType.greatWall→ GreatWallIllustrationWonderType.machuPicchu→ MachuPicchuIllustrationWonderType.petra→ PetraIllustrationWonderType.pyramidsGiza→ PyramidsGizaIllustrationWonderType.tajMahal→ TajMahalIllustration
WonderIllustrationConfig
Location:lib/ui/wonder_illustrations/common/wonder_illustration_config.dart
Configuration object controlling which layers are visible and how they behave.
Full Constructor:
zoom- Scale multiplier (1.0 = default size)isShowing- Controls visibility and animationsenableFg/Bg/Mg- Toggle specific layersenableHero- Use Hero widgets for transitionsenableAnims- Enable entry/exit animationsshortMode- Adjust layout for small screens
WonderIllustrationBuilder
Location:lib/ui/wonder_illustrations/common/wonder_illustration_builder.dart
Base builder widget that handles animation and layer composition.
Internal Structure:
Each wonder illustration uses this builder with three builder functions:
bgBuilder- Builds background layermgBuilder- Builds middleground layerfgBuilder- Builds foreground layer
- 600ms fade-in when
isShowingchanges to true - Opacity animation for smooth transitions
- Curved animation (ease-out)
Illustration Components
IllustrationPiece
Location:lib/ui/wonder_illustrations/common/illustration_piece.dart
Building block for individual illustration elements (PNG assets).
Usage:
heightFactor- Height as fraction of container (0.0-1.0)minHeight- Minimum height in pixels- Aspect ratio calculated automatically from image
alignment- Alignment within parent (default: center)offset- Fixed pixel offsetfractionalOffset- Offset as fraction of piece sizedynamicHzOffset- Additional offset on wide screens
initialOffset- Starting offset (animates to zero)initialScale- Starting scale (animates to 1.0)zoomAmt- How much this piece responds to config.zoom
enableHero- Adds Hero widget with tag{type}-{fileName}top/bottom- Builder functions for overlays
- Auto-detects image aspect ratio
- Smooth entry animations
- Responsive to parent size changes
- OverflowBox prevents clipping during animations
AnimatedClouds
Location:lib/ui/wonder_illustrations/common/animated_clouds.dart
Animated cloud layer that transitions between wonders.
Usage:
wonderType- Current wonder (triggers cloud regeneration)opacity- Cloud transparency (0.0-1.0)cloudSize- Base cloud size in pixelsenableAnimations- Enable slide-in effects
- Generates 3 clouds per wonder with random positions
- Uses seeded random for consistent placement per wonder
- Clouds slide in from sides (±1000px) over 1500ms
- Old clouds fade out as new clouds fade in
- Each wonder has unique cloud seed for variety
IllustrationTexture
Location:lib/ui/wonder_illustrations/common/paint_textures.dart
Applies texture overlays using blend modes.
Usage:
imagePath- Asset path to texture imageflipY- Flip texture verticallyopacity- Animated or static opacitycolor- Tint colorscale- Texture scale multiplier
WonderTitleText
Location:lib/ui/wonder_illustrations/common/wonder_title_text.dart
Stylized title text for wonders.
Usage:
WonderHero
Location:lib/ui/wonder_illustrations/common/wonder_hero.dart
Manages Hero widget animations between screens.
Individual Wonder Illustrations
Each wonder has a dedicated illustration file that defines its layers:Taj Mahal Illustration
Location:lib/ui/wonder_illustrations/taj_mahal_illustration.dart
Layers:
Background:
- Solid color background (fades in)
- Roller texture overlay (70% opacity)
- Sun element (positioned top-left)
- Main Taj Mahal building
- Reflecting pool (positioned below building)
- Mango tree branches (left and right)
- Scale dynamically with screen width
- Parallax zoom effect (0.25x)
Other Wonder Illustrations
All wonders follow the same pattern: ChichenItzaIllustration -chichen_itza_illustration.dart
- Pyramid structure
- Jungle foliage foreground
- Sky and clouds background
christ_redeemer_illustration.dart
- Christ statue
- Mountain backdrop
- Atmospheric layers
colosseum_illustration.dart
- Roman architecture
- Ruins and arches
- Stone textures
great_wall_illustration.dart
- Wall segments
- Mountain ranges
- Watchtowers
machu_picchu_illustration.dart
- Terraced ruins
- Mountain peaks
- Mist effects
petra_illustration.dart
- Treasury facade
- Rock formations
- Desert atmosphere
pyramids_giza_illustration.dart
- Three pyramids
- Desert foreground
- Sun and sky
Implementation Examples
Basic Usage
Single Layer:Parallax Layers
Home Screen Pattern:With Animations
Respond to User Input:Asset Structure
Each wonder has its own asset directory:- PNG format with transparency
- High resolution (2x, 3x for retina)
- Separate layers as individual files
- Consistent naming conventions
Layering Strategy
Background Layer
Purpose: Static backdrop and atmosphere- Solid color fills
- Texture overlays
- Sky elements (sun, moon)
- Far distant elements
Middleground Layer
Purpose: Main subject/wonder- Primary structure
- Hero architectural elements
- Medium-distance objects
- Minimal zoom response
Foreground Layer
Purpose: Depth and framing- Close-up environmental details
- Foliage, branches, rocks
- Strong parallax effect
- High zoom multiplier (0.25-0.4)
Performance Considerations
Optimization Techniques:- RepaintBoundary - Wrap illustrations to isolate repaints:
- Hero Animations - Only enable when needed:
- Conditional Rendering - Skip hidden layers:
- Image Caching - Assets are cached automatically by Flutter
- OverflowBox - Prevents layout recalculations during transforms
Responsive Design
Short Mode: For smaller screens or portrait orientation:Accessibility
Best Practices:- Exclude from Semantics:
- Semantic Descriptions: Add descriptions at the screen level, not individual pieces.
- Reduced Motion: Respect system preferences:
Creating New Illustrations
Steps:- Create asset directory:
- Export layers as PNGs:
- background.png
- main-structure.png
- foreground.png
- Create illustration file:
- Update WonderIllustration switch:
Related
- Screens - How screens use illustrations
- Common Widgets - Shared UI components
- Theming - Theme colors and wonder-specific colors