Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hsgubert/color_palette
https://github.com/hsgubert/color_palette
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hsgubert/color_palette
- Owner: hsgubert
- License: mit
- Created: 2014-08-23T18:29:20.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-23T20:43:21.000Z (over 10 years ago)
- Last Synced: 2024-04-24T21:00:46.677Z (9 months ago)
- Language: Ruby
- Size: 164 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
[![Gem Version](https://badge.fury.io/rb/color_palette.png)](http://badge.fury.io/rb/color_palette)
Color Palette
====================**Making life of a programmer-designer a little easier.**
![alt tag](https://raw.githubusercontent.com/hsgubert/color_palette/master/images/palette_image.jpeg)
Simple gem to build palettes (sequence of colors) of various types based on one or more reference colors.This gem aims to be as simple as possible helping you to create palettes dynamically. No more hard-coding a lot of colors in your ruby code!
# Requirements
- Ruby 2.1 (untested for older versions of ruby, but it might as well work)
# Installation
Run
gem install color_paletteOr add to your gemfile and run bundle install
```ruby
# Gemfile
gem 'color_palette', :require => false
# Terminal
bundle install
```
# Reference### Unidirectional Palette
A unidirectional palette is a a palette that goes from a start color to an end color. The colors in between are linearly interpolated between both start and end colors. See examples of unidirectional palettes below:
![alt tag](https://raw.githubusercontent.com/hsgubert/color_palette/master/images/example1.png)
![alt tag](https://raw.githubusercontent.com/hsgubert/color_palette/master/images/example2.png)
![alt tag](https://raw.githubusercontent.com/hsgubert/color_palette/master/images/example3.png)
![alt tag](https://raw.githubusercontent.com/hsgubert/color_palette/master/images/example4.png)Here is how to create palettes like these using the color_palette gem:
```ruby
# ColorPalette.unidirectional(end_color, palette_size, start_color = white)# Creating palette from white to red, with 5 colors
ColorPalette.unidirectional('#ff0000', 5)
# => ["#ffffff", "#ffbfbf", "#ff8080", "#ff4040", "#ff0000"]# Creating palette from white to green, with 3 colors
ColorPalette.unidirectional('#00FF00', 3)
# => ["#ffffff", "#80ff80", "#00ff00"]# Creating palette from black to blue, with 4 colors
ColorPalette.unidirectional('#0000FF', 4, '#000000')
# => ["#000000", "#000055", "#0000aa", "#0000ff"]# Creating palette from red to green, with 10 colors
ColorPalette.unidirectional('#00FF00', 6, '#FF0000')
# => ["#ff0000", "#cc3300", "#996600", "#669900", "#33cc00", "#00ff00"]
```### Color Formats
The colors may be specified with or without hashtag, and in 6 digit code or 3 digit code. Codes are case insensitive. Examples of specifying the red color:
```ruby
'#FF0000'
'#ff0000'
'FF0000'
'ff0000'
'#F00'
'#f00'
'F00'
'f00'
```