Lightweight, feature-rich JavaScript library for creating beautiful, animated backgrounds with shapes and images.
Transform your website with stunning animated backgrounds in seconds!
- 🎨 18+ Unique Shapes - Stars, hearts, fractals, and more
- 🖼️ Image Support - Use custom images as background elements
- ✨ Smooth Animations - Floating, rotating, and hover effects
- 🖱️ Interactive - Click and hover event handlers
- ⚙️ Fully Configurable - Customize colors, sizes, counts, and animations
- 📱 Responsive - Works perfectly on all screen sizes
- 📦 Lightweight - Only ~5KB (minified)
- 🔓 No Dependencies - Pure vanilla JavaScript
- 🎯 Easy Integration - Copy-paste one line of code
Include the script in your HTML:
<script src="https://cdn.jsdelivr.net/gh/Ali-Cheikh/scape.js@main/scape.js"></script>document.addEventListener('DOMContentLoaded', () => {
window.ScapeConfig = {
type: 'shape',
shape: 'star',
count: 30,
fillColor: 'hsla(200, 90%, 60%, 0.8)'
};
});Done! Your background now has beautiful animated stars. ⭐
window.ScapeConfig = {
type: 'shape',
shape: 'heart',
count: 25,
size: 50,
fillColor: '#ff69b4',
strokeColor: 'transparent',
animationDuration: '4s'
};window.ScapeConfig = {
type: 'image',
imageUrl: 'logo.png',
count: 20,
size: 60,
opacity: 0.7,
spacing: 150
};window.ScapeConfig = {
type: 'shape',
shape: 'hexagon',
count: 30,
onClick: (event) => {
console.log('Clicked!', event.target);
},
onHover: (event) => {
event.target.style.filter = 'brightness(1.5)';
}
};| Method | Description | Example |
|---|---|---|
refresh() |
Regenerate background | ScapeJs.refresh() |
updateConfig(config) |
Update configuration | ScapeJs.updateConfig({ shape: 'heart' }) |
destroy() |
Remove all elements | ScapeJs.destroy() |
setImage(url) |
Change image | ScapeJs.setImage('new.png') |
setShape(shape) |
Change shape | ScapeJs.setShape('star') |
pause() |
Pause animations | ScapeJs.pause() |
resume() |
Resume animations | ScapeJs.resume() |
getConfig() |
Get current config | const cfg = ScapeJs.getConfig() |
circle · hexagon · triangle · diamond · pentagon
heart · flower · shell · spiral · splash
star · fly · clover · ripple · wave
tesseract · boom · snowflake · fractal
| Option | Type | Default | Notes |
|---|---|---|---|
type |
string | 'image' | 'shape' or 'image' |
count |
number | 30 | Number of elements |
size |
number | 50 | Element size (pixels) |
opacity |
number | 0.8 | Base opacity (0-1) |
animationDuration |
string | '3s' | Duration of animation |
floatDistance |
number | 30 | Float animation distance |
| Option | Type | Default |
|---|---|---|
shape |
string | 'heart' |
fillColor |
string | 'hsla(200, 90%, 60%, 0.8)' |
strokeColor |
string | 'rgba(255, 255, 255, 0.5)' |
strokeWidth |
number | 2 |
| Option | Type | Default |
|---|---|---|
imageUrl |
string | githubImg |
spacing |
number | 200 |
minDistance |
number | 150 |
Add eye-catching animated backgrounds to make your landing page stand out.
Showcase your creativity with custom animated backgrounds that reflect your style.
Turn error pages into engaging experiences with floating shapes.
Add subtle animations to your blog post headers.
Highlight key features with animated shape backgrounds.
| Browser | Version | Support |
|---|---|---|
| Chrome | 90+ | ✅ Full |
| Firefox | 88+ | ✅ Full |
| Safari | 14+ | ✅ Full |
| Edge | 90+ | ✅ Full |
| Mobile | Latest | ✅ Full |
- Keep count reasonable - Use 15-50 elements for best performance
- Responsive design - Reduce count on mobile devices
- Optimize size - Smaller shapes render faster
- Test performance - Check on your target devices
// Mobile optimization example
const isMobile = window.innerWidth < 768;
window.ScapeConfig = {
type: 'shape',
shape: 'star',
count: isMobile ? 15 : 30,
size: isMobile ? 30 : 50
};MIT License - Free for personal and commercial use
- GitHub - Ali-Cheikh/scape.js
- Live Demo - Interactive Demo
- Documentation - Full Docs
- NPM - Coming soon
Contributions welcome! Feel free to submit issues and pull requests.
Made with ❤️ by Ali Cheikh
trianglepentagondiamond
heartstarflyflowerspiral
splashtesseractboomwaveclover
rippleshellfractalsnowflake
window.ScapeConfig = {
// ...other options
onClick: (event) => {
const element = event.target;
// Handle click
},
onHover: (event) => {
const element = event.target;
// Handle hover
}
};document.addEventListener('DOMContentLoaded', () => {
window.ScapeConfig = {
type: 'shape',
shape: 'heart',
count: 15,
hoverScale: 1.2,
onClick: (e) => {
e.target.style.fillColor = 'red';
}
};
});-
Element Count
- Mobile: 10-20 elements
- Desktop: 20-40 elements
- High-performance: up to 100 elements
-
Animation Performance
- Use simpler shapes for better performance
- Reduce floatDistance on mobile
- Consider disabling rotation on low-end devices
-
Memory Management
- Always use
Scape.destroy()before page unload - Clean up event listeners when removing elements
- Use appropriate spacing values
- Always use
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Partial support for IE11
If elements don't appear:
- Check console for errors
- Verify DOM is loaded
- Check z-index conflicts
- Verify shape type is valid
- Check image URLs for image type
- v1.0.1: Added new shapes, improved performance
- v1.0.0: Initial release For detailed configuration options, see the documentation.