Skip to content

Commit

Permalink
Fix to make_color with a base_color
Browse files Browse the repository at this point in the history
  • Loading branch information
Fooidge committed Sep 16, 2014
1 parent 38dd830 commit f86f673
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pleasejs",
"version": "0.2.5",
"version": "0.2.6",
"homepage": "https://github.com/Fooidge/PleaseJS",
"authors": [
"Fooidge"
Expand Down
4 changes: 2 additions & 2 deletions dist/Please.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pleasejs",
"version": "0.2.5",
"version": "0.2.6",
"description": "JS library to generate random pleasing colors/color schemes",
"main": "Please.js",
"scripts": {
Expand Down
11 changes: 6 additions & 5 deletions src/Please.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!Please JS v0.2.5, Jordan Checkman 2014, Checkman.io, MIT License, Have fun.*/
/*!Please JS v0.2.6, Jordan Checkman 2014, Checkman.io, MIT License, Have fun.*/
(function( globalName, root, factory ) {
if ( typeof define === 'function' && define.amd ) {
define( [], factory );
Expand Down Expand Up @@ -508,7 +508,8 @@
Please.make_color = function( options ){
var color = [];
//clone base please options
var color_options = copy_object( make_color_default );
var color_options = copy_object( make_color_default ),
base_color = null;

if( options !== null ){
//override base Please options
Expand All @@ -520,13 +521,13 @@
}
//first, check for a base color
if ( color_options.base_color.length > 0 ) {
color_options.base_color = Please.NAME_to_HSV( color_options.base_color );
base_color = Please.NAME_to_HSV( color_options.base_color );
}
for ( var i = 0; i < color_options.colors_returned; i++ ) {
var random_hue = random_int( 0, 360 );
var hue,saturation,value;
if( color_options.base_color.length > 0 ){
hue = clamp( random_int( ( color_options.base_color.h - 5 ), ( color_options.base_color.h + 5 )), 0, 360);
if( base_color !== null ){
hue = clamp( random_int( ( base_color.h - 5 ), ( base_color.h + 5 )), 0, 360);
saturation = random_float( 0.4, 0.85 );
value = random_float( 0.4, 0.85 );
color.push({h: hue, s: saturation, v: value});
Expand Down

0 comments on commit f86f673

Please sign in to comment.