Giter Site home page Giter Site logo

softpunch / sky-color-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karenpeng/sky-color-generator

0.0 2.0 0.0 568 KB

a npm module that generates color based on time

Home Page: https://www.npmjs.com/package/sky-color-generator

JavaScript 100.00%

sky-color-generator's Introduction

Sky Color Generator

For those who is mimicking color changes within a day, this module does the calculation for you ๐Ÿ˜‰

You could set color for certain time points, and get back a color with any given time in a day.

Usage

initianize the color generator
var SkyColor = require('sky-color-generator')

var skyColor = new SkyColor()
skyColor.init(h * 60 + m)
set color for time you want
//first parameter is time, it could be how many minutes in a day or a ISO 8601 format time
//second parameter is color, sorry it only supports an array of rgba color now

//set a blue-ish color for 7am in the morning
skyColor.set(420, [96, 168, 232, 0.5]);

//be careful 0am should have the same color as 24pm
skyColor.set(0, [160, 222, 255, 1]);
skyColor.set(1440, [160, 222, 255, 1]);
query color with given time
//get back a rgba color string with a given time
//put this in an animation loop and you will get nice gradient effect :)
color = skyColor.get(h * 60 + m)
start a new day!
//when a new day comes, please reset the color generator
skyColor.startDay()
check out the example if this still doesn't make sense

๐Ÿ˜Ž

sky-color-generator's People

Watchers

James Cloos avatar Ryan avatar

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.