Merge pull request #1149 from paulkaplan/randomize-pretty-colors

Only pick random colors with full saturation and brightness
This commit is contained in:
Paul Kaplan 2017-10-18 13:16:51 -04:00 committed by GitHub
commit 2c9d126ed6

View file

@ -26,17 +26,18 @@
goog.provide('Blockly.Blocks.colour');
goog.require('goog.color');
goog.require('Blockly.Blocks');
goog.require('Blockly.constants');
/**
* Pick a random colour.
* Pick a random colour that has full saturation and brightness.
* @return {string} #RRGGBB for random colour.
*/
function randomColour() {
var num = Math.floor(Math.random() * Math.pow(2, 24));
return '#' + ('00000' + num.toString(16)).substr(-6);
return goog.color.hsvToHex(360 * Math.random(), 1, 255);
}
Blockly.Blocks['colour_picker'] = {