For further extensions, you can also play around with changing the start hat shape or the jagged teeth shape.
Themes are a way to adjust colors in Blockly. We have a number of built-in themes found under the core/themes directory. You can switch between these themes in the playground using the theme dropdown.
You can find more theming documentation here.
Theme configuration is split into multiple groups:
- Block colors: control the color of blocks by category
- Category colors: control the toolbox category color
- Component colors: controls Blockly UI component colors
Blockly UI component configuration is still a work in progress. For a list of currently supported configuration options, see: https://github.com/google/blockly/issues/3113
- The Material theme is a good starting point for playing around with theme colors.
- If you’re a Star Trek fan, you could use the LCARS UI as inspiration!
The RenderInfo object houses all the information we need to complete our rendering. This is where we look at a block’s various properties and components (next, prev, fields, inputs, connections) and populate rows and elements that are then sent over to the drawer to draw.
As a fun way to get started with render info, let’s make a renderer that doesn’t show any label fields. To do that, we’ll override the createRows_ function in our renderer and won’t add any fields that are of type FieldLabel when populating our row.
Start by copying the createRows_ method from renderers/common/info.js and pasting it into our renderer’s RenderInfo object, ie: renderers/minimalist/info.js.
Change the method name from Blockly.blockRendering.RenderInfo.prototype.createRows_ to Blockly.minimalist.RenderInfo.prototype.createRows_. This overrides the createRows_ method in the base class.
In the for loop that iterates through an input’s fields and adds Field measurables to the active row, add an if statement that checks whether the current field is an instance of Blockly.FieldLabel. Only add the field to the row if it’s not.
// All of the fields in an input go on the same row.
for (var j = 0, field; (field = input.fieldRow[j]); j++) {
if (!(field instanceof Blockly.FieldLabel)) {
activeRow.elements.push(
new Blockly.blockRendering.Field(this.constants_, field, input));
}
}
You should end up with blocks that look like this: