Giter Site home page Giter Site logo

h0rn0chse / nightsky Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 10.85 MB

WebComponent for a night sky full of stars parallax background made with css only

Home Page: https://h0rn0chse.github.io/NightSky

License: MIT License

JavaScript 97.78% CSS 2.22%
webcomponent night sky nightsky star field starfield background parallax

nightsky's Introduction

NightSky

This WebComponent is inspired by the CodePen Parallax Star background in CSS from Saransh Sinha. Since this is a WebComponent it can be easily integrated in any React or Vue app. Check out the live demo.

Libraries

Usage

Please checkout the demo. You can add the resources either locally or via a CDN (or as npm package):

<script src="https://unpkg.com/@h0rn0chse/night-sky/dist/bundle.min.js"></script>

You can add the background as WebComponent.

<night-sky
  id="nightSky"
  layers="4"
  density="30"
  velocity-x="60"
  velocity-y="60"
  star-color="#FFF"
  background-color="transparent"
>
</night-sky>

You have to set a size on the background.

#nightSky {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

Documentation

The WebComponent allows for some customizations via its attributes:

layers

The amount of layers provided as positive integer.

density

density describes the amount of stars in the first layer in screen with 192x1080px. Each additional layer doubles the amount of stars. It should be provided as positive integer.

velocity-x

velocity-x describes the speed of the last layer. Each layer above moves with nth time of this speed. It should be provided as positive or negative integer.

velocity-y

velocity-y describes the speed of the last layer. Each layer above moves with nth time of this speed. It should be provided as positive or negative integer.

star-color

star-color is the color of the star. It should be provided as valid css color.

background-color

background-color currently only supports the value transparent to disable the predefined background.

nightsky's People

Contributors

h0rn0chse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

renanlecaro

nightsky's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.