Override default color values for default blocks.

568 views
Skip to first unread message

Fran

unread,
May 16, 2016, 7:19:10 AM5/16/16
to Blockly
I would like to change the default color for default blocks. For example, change the default color of math_number block. I know that you can change the color to different categories so I tried doing it in the same way:

<category name="Maths" colour="120">
<block type="math_number" colour="120"></block>
</category>

but it does not work. 

Do you have any idea how can I get it?

Thanks!

Miguel

unread,
May 16, 2016, 9:33:59 AM5/16/16
to Blockly
Hi,
if you have a look at the source code, under the directory blocks, you can find the code for the different standard blocks.
In each of the js files there is a constant with the color of a category.

For example in math.js you can see the line:

Blockly.Blocks.math.HUE = 230;

You need to change that value, but you don't need to change the Blockly source code for that. 
You can just change that value in your javascript before injecting the workspace.

The same goes for the other categories, just look for the corresponding .HUE constants in each of those js files.

Best Regards,
Miguel


--
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.
Reply all
Reply to author
Forward
0 new messages