All Projects → zuramai → starback.js

zuramai / starback.js

Licence: other
Create a beautiful star falling background with starback.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to starback.js

Vivify
Vivify is free CSS animation library.
Stars: ✭ 1,651 (+389.91%)
Mutual labels:  css-animations
Term Sheets
Create animated terminal presentations. Export as SVG, animated GIF, or HTML+CSS
Stars: ✭ 243 (-27.89%)
Mutual labels:  css-animations
typed.css
A fully functional and flexible typewriter mixin for SCSS, with Less and Stylus support coming soon! Typed.css supports multiple strings, multi-line strings, variable speeds, per-string styling, animated caret (blinking insertion cursor), directional type-pausing, and much more. It's even accessible! ✨
Stars: ✭ 113 (-66.47%)
Mutual labels:  css-animations
Slide And Swipe Menu
⚡️ A sliding swipe menu that works with touchSwipe library.
Stars: ✭ 135 (-59.94%)
Mutual labels:  css-animations
Cssanimation.io
CSS Animation Library for Developers and Ninjas
Stars: ✭ 176 (-47.77%)
Mutual labels:  css-animations
sshbg
Change terminal background when SSH'ing (on specific terminals)
Stars: ✭ 45 (-86.65%)
Mutual labels:  background
Justified Gallery
Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
Stars: ✭ 1,512 (+348.66%)
Mutual labels:  css-animations
bookmarks
Bookmarks that I ❤️
Stars: ✭ 151 (-55.19%)
Mutual labels:  css-animations
Micron
a [μ] microInteraction library built with CSS Animations and controlled by JavaScript Power
Stars: ✭ 2,252 (+568.25%)
Mutual labels:  css-animations
helium-animated-pages
A light spiritual succesor to neon-animated-pages using only css animations
Stars: ✭ 17 (-94.96%)
Mutual labels:  css-animations
Animatopy
🎩 Just-add-water simple CSS animations snippets
Stars: ✭ 137 (-59.35%)
Mutual labels:  css-animations
React Site Nav
A kick ass site menu powered by styled components inspired by Stripe.
Stars: ✭ 155 (-54.01%)
Mutual labels:  css-animations
android-multibackground
This library can easily apply round corner、stroke、shadow and different state effects to background drawable.
Stars: ✭ 18 (-94.66%)
Mutual labels:  background
Thegoodman
An experiment with basic CSS3 animations.
Stars: ✭ 128 (-62.02%)
Mutual labels:  css-animations
MonsterJS
MonsterJS - a game for learning JavaScript DOM Selectors while playing!
Stars: ✭ 26 (-92.28%)
Mutual labels:  css-animations
Tinseltown.js
A lightweight CSS/JS library for faux hacker-movie-style page loading effects
Stars: ✭ 113 (-66.47%)
Mutual labels:  css-animations
Animate.css
🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.
Stars: ✭ 73,073 (+21583.38%)
Mutual labels:  css-animations
time
The simplest but configurable online clock
Stars: ✭ 77 (-77.15%)
Mutual labels:  background
vitrina-legacy
A companion app for Muzei that fetches images from Reddit
Stars: ✭ 23 (-93.18%)
Mutual labels:  background
iterative-grabcut
This algorithm uses a rectangle made by the user to identify the foreground item. Then, the user can edit to add or remove objects to the foreground. Then, it removes the background and makes it transparent.
Stars: ✭ 35 (-89.61%)
Mutual labels:  background

Starbackjs Starbackjs Demo Night

Click for more examples

Starback.js

Getting Started

You can use starback.js directly with <script> tag or import syntax.

  • With <script> tag

    # Using CDN
    <script src="https://unpkg.com/[email protected]/dist/starback.global.js"></script>
    
    # Using downloaded files
    <script src="PATH_TO_YOUR_DIST_FOLDER/starback.js"></script>
  • With import

    Install via NPM first:

    npm install starback

    and then

    import Starback from 'starback'

Example Usage

<canvas id="canvas"></canvas>

<script src="PATH_TO_DIST_FOLDER/starback.js"></script>
<script>
  const canvas = document.getElementById('canvas')
  const starback = new Starback(canvas, {
      type: 'dot',
      quantity: 100,
      direction: 225,
      backgroundColor: ['#0e1118', '#232b3e'],
      randomOpacity: true,
  })
</script>

You can check the more options in Options section

Options

Key Type Description Required Default Value
type String Required. Star type to use. The values are 'dot' or 'line' true
width Number Canvas width to set no 800
height Number Canvas height to set no 600
backgroundColor String|Array Color of the background, use string for solid color, or array of colors for linear gradient no #ccc
quantity Number Number of stars to show no 100
showFps Boolean Show FPS on the top left screen no false
speed Number Star speed no 0.5
starSize Number|Array Use number for fixed star size. Use [minSize, maxSize] value for random the size within the range no [0, 3] for type: dot, 100 for type: line

Additional options for type: 'dot'

Key Type Description Required Default Value
direction Number Use 360 degree to set the direction no 225
randomOpacity Boolean|Array If true, random star will get random opacity. Use array [minOpacity, maxOpacity] to limit the random opacity no false
starColor String Color of the stars, you can use rgb or hex like css color. no white

Additional options for type: 'line'

Key Type Description Required Default Value
directionY Number The direction the star to move vertically (1 = to bottom, 0 = to top) no 1
directionX Number The direction the star to move vertically (1 = to right, 0 = to left) no 1
distanceX Number Distance horizontally the star should reaching at no 0.1
frequency Number The frequency of star will be rotated no 10
slope Object The quadraticCurve coordinate that will be applied to stars. Read MDN no {x: 1, y: 1}
starColor String|Array Color of the stars, use string for solid color, or array of colors for linear gradient no ['#fb00ff', '#00dde0']
spread Number The spread level of the stars no 1

Methods

Name Parameter Description
generateStar(amount) amount: number The quantity of stars that will be shown
addToFront(callback(ctx)) function(ctx: CanvasRenderingContext2D) Add to front of the falling star by given context
addToBehind(callback(ctx)) function(ctx: CanvasRenderingContext2D) Add to back of the falling star by given context

Example method usage: adding image to front

let starback = new Starback(canvas, options)

let mountainImage = new Image()
mountainImage.src = 'images/mountain.png'

mountainImage.onload = () => {
  starback.addToFront((ctx) => {
    ctx.drawImage(
      mountain,
      0,
      0,
      mountain.width,
      mountain.height,
      0,
      canvas.height - mountain.height,
      canvas.width,
      mountain.height
    )
  })
}

Contributing

You can contribute to this repository. See CONTRIBUTING.md

Donate

If you have used this library and it's useful for you, please consider to donate:

Ko-fi | Trakteer

License

This library is under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].