0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-12 16:08:50 -05:00

removed Common.shadeColor

This commit is contained in:
liabru 2017-05-09 00:40:16 +01:00
parent 2b76c4c10b
commit d63b0c25c8
2 changed files with 2 additions and 21 deletions

View file

@ -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);
@ -1109,7 +1109,7 @@ var Axes = require('../geometry/Axes');
*
* @property render.lineWidth
* @type number
* @default 1.5
* @default 0
*/
/**

View file

@ -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.