How to change the colour of the Blocks

1,405 views
Skip to first unread message

Juan Salce

unread,
Nov 26, 2014, 11:46:43 AM11/26/14
to blo...@googlegroups.com
Hello 

I wanted to know how to change the colour of the Blockly Blocks. Thank you for everyones help.

Carlos Galarza

unread,
Nov 26, 2014, 1:57:16 PM11/26/14
to blo...@googlegroups.com
You can do that modifing the source code. For example, if you wants to change the 'if' block:

- go to blocks/logic.js
- search for 'Blockly.Blocks['controls_if']' object and change the line 'this.setColour(210);' for your colour. Note that block colour is in HSV format.

If want to change the range of colours, you can modify in core/blockly.js the lines 'Blockly.HSV_SATURATION = 0.45;' and 'Blockly.HSV_VALUE = 0.65;' by which you need.

Neil Fraser

unread,
Nov 26, 2014, 2:02:48 PM11/26/14
to blo...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Juan Salce

unread,
Nov 26, 2014, 2:48:25 PM11/26/14
to blo...@googlegroups.com
Thanks guys!

Andrew Stratton

unread,
Dec 8, 2014, 7:01:33 PM12/8/14
to blo...@googlegroups.com
You can also just change the saturation and value in an included .js (which needs to be after the blockly script src include), e.g.

Blockly.HSV_SATURATION = 0.75; 
Blockly.HSV_VALUE = 0.75;  

So, this way you don't need to modify the core/blockly.js
Reply all
Reply to author
Forward
0 new messages