Skip to content

Commit

Permalink
removed Common.shadeColor
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed May 8, 2017
1 parent 2b76c4c commit d63b0c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/body/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var Axes = require('../geometry/Axes');

// render properties
var defaultFillStyle = (body.isStatic ? '#2e2b44' : Common.choose(['#006BA6', '#0496FF', '#FFBC42', '#D81159', '#8F2D56'])),
defaultStrokeStyle = Common.shadeColor(defaultFillStyle, -20);
defaultStrokeStyle = '#000';
body.render.fillStyle = body.render.fillStyle || defaultFillStyle;
body.render.strokeStyle = body.render.strokeStyle || defaultStrokeStyle;
body.render.sprite.xOffset += -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x);
Expand Down Expand Up @@ -1109,7 +1109,7 @@ var Axes = require('../geometry/Axes');
*
* @property render.lineWidth
* @type number
* @default 1.5
* @default 0
*/

/**
Expand Down
19 changes: 0 additions & 19 deletions src/core/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,6 @@ module.exports = Common;
return val;
};

/**
* Returns a hex colour string made by lightening or darkening color by percent.
* @method shadeColor
* @param {string} color
* @param {number} percent
* @return {string} A hex colour
*/
Common.shadeColor = function(color, percent) {
// http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color
var colorInteger = parseInt(color.slice(1),16),
amount = Math.round(2.55 * percent),
R = (colorInteger >> 16) + amount,
B = (colorInteger >> 8 & 0x00FF) + amount,
G = (colorInteger & 0x0000FF) + amount;
return "#" + (0x1000000 + (R < 255 ? R < 1 ? 0 : R :255) * 0x10000
+ (B < 255 ? B < 1 ? 0 : B : 255) * 0x100
+ (G < 255 ? G < 1 ? 0 : G : 255)).toString(16).slice(1);
};

/**
* Shuffles the given array in-place.
* The function uses a seeded random generator.
Expand Down

0 comments on commit d63b0c2

Please sign in to comment.