From f5da6f6fb3fcbbd97119d012e41ed4777175188f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Tue, 10 May 2016 17:46:46 +0200 Subject: [PATCH] Use core generator with specific values --- js/app/directives/colorpickerDirective.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/js/app/directives/colorpickerDirective.js b/js/app/directives/colorpickerDirective.js index 1fe0a4a42..16e3af5c8 100644 --- a/js/app/directives/colorpickerDirective.js +++ b/js/app/directives/colorpickerDirective.js @@ -97,16 +97,17 @@ app.directive('colorpicker', function() { '#CACBCD' ]; if (typeof String.prototype.toHsl === 'function') { - var hsl = "".toHsl(); - listofcolours = []; - for (var colour = 0; colour < 9; colour++) { - var hslcolour = hslToRgb(colour * 40, hsl[1] / 100, hsl[2] / 100); - listofcolours.push( - '#' + parseInt(hslcolour[0], 10).toString(16) + - parseInt(hslcolour[1], 10).toString(16) + - parseInt(hslcolour[2], 10).toString(16) - ); - } + var hsl = ""; + var hslcolour = ""; + // 0 40 80 120 160 200 240 280 320 + listofcolours = ["15", "9", "4", "b", "6", "11", "e", "f", "57"]; + listofcolours.forEach(function(hash, index) { + hsl = hash.toHsl(); + hslcolour = hslToRgb(Math.round(hsl[0]/40)*40, hsl[1]/100, hsl[2]/100); + listofcolours[index] = '#' + parseInt(hslcolour[0], 10).toString(16)+ + parseInt(hslcolour[1], 10).toString(16)+ + parseInt(hslcolour[2], 10).toString(16) + }); } return { scope: {