mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Merge pull request #1149 from paulkaplan/randomize-pretty-colors
Only pick random colors with full saturation and brightness
This commit is contained in:
commit
2c9d126ed6
1 changed files with 4 additions and 3 deletions
|
@ -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'] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue