Gathering detailed insights and metrics for expo-pixel-perfect
Gathering detailed insights and metrics for expo-pixel-perfect
Gathering detailed insights and metrics for expo-pixel-perfect
Gathering detailed insights and metrics for expo-pixel-perfect
npm install expo-pixel-perfect
Typescript
Module System
Node Version
NPM Version
TypeScript (42.75%)
Swift (24.3%)
Kotlin (23.16%)
Ruby (6.2%)
JavaScript (3.4%)
C (0.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
23 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jun 05, 2025
Latest Version
1.0.21
Package Id
expo-pixel-perfect@1.0.21
Unpacked Size
285.57 kB
Size
186.00 kB
File Count
39
NPM Version
10.2.3
Node Version
20.10.0
Published on
Jun 05, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
4
4
Perfect pixel-art scaling for your Expo apps. No blur, no artifacts - just crisp, clean pixels.
Platform | Supported |
---|---|
iOS | ✅ New Architecture |
Android | ✅ New Architecture |
Web | ❌ |
Note: This module requires the New Architecture (Fabric) to be enabled in your Expo project. It will not work with the old architecture.
Web Platform: This module uses native implementations for pixel-perfect scaling and does not support web platforms. For web-specific pixel art needs, consider using CSS solutions or a web-specific library.
1npx expo install expo-pixel-perfect
1import ExpoPixelPerfectView from 'expo-pixel-perfect'; 2 3export default function Game() { 4 return ( 5 <ExpoPixelPerfectView 6 source={require('./assets/sprite.png')} 7 scale={4} 8 /> 9 ); 10}
1import ExpoPixelPerfectView from 'expo-pixel-perfect'; 2 3export default function Game() { 4 return ( 5 <ExpoPixelPerfectView 6 // Source image 7 source={require('./assets/sprite.png')} 8 9 // Scale to specific width 10 scale={{ targetWidth: 64 }} 11 12 // Use optimized algorithm for non-integer scaling 13 scaleMode="fractional-optimized" 14 15 // Platform-specific rendering modes 16 android_renderMode="software" // Higher quality on Android 17 ios_renderMode="software" // Higher quality on iOS 18 19 // Custom loading component 20 loadingComponent={<CustomLoader />} 21 22 // Error handling 23 fallback={<Text>Failed to load sprite</Text>} 24 onError={(error) => console.error('Failed to load:', error)} 25 26 // Load callback 27 onLoad={() => console.log('Sprite loaded successfully')} 28 29 // Standard React Native styles 30 style={styles.sprite} 31 /> 32 ); 33}
1import ExpoPixelPerfectView from 'expo-pixel-perfect'; 2 3export default function Game() { 4 // Base64 encoded pixel art 5 const pixelArtBase64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...'; 6 7 return ( 8 <ExpoPixelPerfectView 9 source={{ 10 base64: pixelArtBase64, 11 width: 16, // Original width is required 12 height: 16 // Original height is required 13 }} 14 scale={3} 15 /> 16 ); 17}
1import ExpoPixelPerfectView from 'expo-pixel-perfect'; 2import { useWindowDimensions } from 'react-native'; 3 4export default function ResponsiveGameElement() { 5 const { width } = useWindowDimensions(); 6 const spriteOriginalWidth = 32; 7 8 // Calculate a non-integer scale factor to fit screen width 9 const scaleFactor = width / spriteOriginalWidth / 2; // Fit 2 sprites side by side 10 11 return ( 12 <ExpoPixelPerfectView 13 source={require('./assets/game-element.png')} 14 scale={scaleFactor} 15 scaleMode="fractional-optimized" // Use optimized scaling for non-integer scales 16 /> 17 ); 18}
Prop | Type | Description |
---|---|---|
source | number | { uri: string } | { base64: string, width: number, height: number } | Image source (local, remote, or base64) |
Prop | Type | Default | Description |
---|---|---|---|
scale | number | { targetWidth: number } | { targetHeight: number } | 1 | Scaling factor or target dimensions |
style | ViewStyle | undefined | Standard React Native view styles |
loadingComponent | ReactNode | null | Component shown during loading |
fallback | ReactNode | null | Component shown on error |
onError | (error: Error) => void | undefined | Error callback |
onLoad | () => void | undefined | Success callback |
scaleMode | "nearest" | "fractional-optimized" | "nearest" | Algorithm used for scaling |
android_renderMode | "software" | "hardware" | "hardware" | Android-specific rendering mode |
ios_renderMode | "software" | "hardware" | "hardware" | iOS-specific rendering mode |
This module provides platform-specific rendering modes to balance between visual quality and performance:
1// Example of platform-specific optimization 2<PixelImage 3 source={require('./assets/character.png')} 4 scale={4} 5 // Use software rendering on Android for best quality 6 android_renderMode="software" 7 // Use hardware acceleration on iOS for better performance 8 ios_renderMode="hardware" 9/>
This module offers two different scaling algorithms to handle different types of pixel art scaling:
scaleMode="nearest"
)scaleMode="fractional-optimized"
)1// Responsive UI with sharp pixel art 2<PixelImage 3 source={require('./assets/ui-element.png')} 4 scale={deviceWidth / spriteWidth} // Non-integer scale to fit screen 5 scaleMode="fractional-optimized" 6/>
Make sure you're using the correct scale factor. For a 16x16 image to display at 64x64, use either:
1scale={4} 2// or 3scale={{ targetWidth: 64 }}
For non-integer scaling that still looks crisp, use the fractional-optimized mode:
1scale={3.2} // Non-integer scale 2scaleMode="fractional-optimized"
If still blurry, try using the "software" rendering mode:
1android_renderMode="software" 2ios_renderMode="software"
Check that your asset path is correct and the image exists. The onError callback can help debug:
1onError={(error) => console.error('Loading failed:', error)}
When using base64 images, you must specify the original width and height:
1source={{ 2 base64: myBase64String, 3 width: 16, // Important! Must be exact 4 height: 16 // Important! Must be exact 5}}
1// This 2<PixelImage 3 source={require('./assets/important-button.png')} 4 scale={2.5} 5 scaleMode="fractional-optimized" 6/> 7 8// This will be slightly blurry 9<PixelImage 10 source={require('./assets/background-element.png')} 11 scale={2.5} 12 scaleMode="nearest" 13/>
Made for ⚔️ Pixel Odyssey by Lino Iten
No vulnerabilities found.
No security vulnerabilities found.