Documentation Index
Fetch the complete documentation index at: https://mintlify.com/soymatudev/Pokedex-Fleek/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Color Analysis system is the core algorithm that identifies Pokémon based on the dominant color of scanned objects. It uses react-native-image-colors to extract colors and a custom HSL hue-based matching system to map colors to Pokémon.Color Extraction
Using react-native-image-colors
After capturing a photo, the dominant color is extracted:Platform Differences
- Android: Uses
result.dominant- the most dominant color in the image - iOS: Uses
result.background- the background color detected by the algorithm
Hex to Hue Conversion
The extracted hex color is converted to an HSL hue value (0-360°):Algorithm Breakdown
- Normalize hex: Ensure hex string is properly formatted
- Convert to RGB: Parse hex values to RGB components (0-1)
- Find max/min: Determine the maximum and minimum RGB values
- Calculate hue: Use the HSL hue formula based on which component is dominant
- Convert to degrees: Multiply by 60 to get hue in 0-360° range
Pokémon Color Database
ThePOKEMON_DB object maps Pokémon to color ranges:
Color Range Categories
Green (80° - 160°)
- Bulbasaur, Ivysaur, Venusaur
- Caterpie, Metapod
- Bellsprout
Red/Orange (0° - 40°)
- Charmander, Charmeleon, Charizard
- Vulpix, Growlithe
- Magmar
Blue (170° - 260°)
- Squirtle, Wartortle, Blastoise
- Psyduck, Lapras
Yellow (45° - 75°)
- Pikachu, Raichu
- Electabuzz, Zapdos
Purple/Pink (270° - 350°)
- Clefairy, Jigglypuff
- Gastly, Gengar
- Mewtwo, Mew
Gray/Brown (Low Saturation)
- Geodude, Onix
- Uses full hue range with saturation constraint
Matching Algorithm
The hue value is compared against the color ranges:Random Selection from Matches
For manual scans, if multiple Pokémon share a color range, one is randomly selected:UI Theme Colors
Each Pokémon entry includes auiTheme color for consistent UI styling:
Example Color Ranges
| Color | Hue Range | Example Pokémon | Hex Example |
|---|---|---|---|
| Red | 0° - 40° | Charmander | #F08030 |
| Yellow | 45° - 75° | Pikachu | #F8D030 |
| Green | 80° - 160° | Bulbasaur | #4E8234 |
| Blue | 170° - 260° | Squirtle | #6890F0 |
| Purple | 270° - 320° | Gengar | #705898 |
| Pink | 270° - 350° | Clefairy | #EE99AC |
Workflow
- User scans object with camera
- Photo is captured
- Dominant color is extracted (hex)
- Hex is converted to HSL hue (0-360°)
- Hue is matched against Pokémon color ranges
- Matching Pokémon is selected (random if multiple matches)
- User is navigated to Pokémon details
Future Enhancements
Potential improvements to the color analysis system:- Saturation filtering: Better handling of gray/brown colors
- Multi-color detection: Match Pokémon with multiple dominant colors
- Machine learning: Train a model to recognize Pokémon more accurately
- Confidence scoring: Show match confidence to users
See Also
- Camera Scanner - Where color analysis is triggered
- Pokédex Entries - Where matched Pokémon are displayed