-
Notifications
You must be signed in to change notification settings - Fork 88
Drawing stuff
borealis uses nanovg (nvg) to draw stuff on screen. Look at the nvg documentation to know what you can do with borealis!
Every view has an alpha
attribute which corresponds to their transparency multiplied by the one of their parent. It means that a hidden BoxLayout
will have all its children hidden as well.
The View
class has helper methods to easily apply that transparency system to nanovg colors:
- The
a
method takes anNVGColor
, applies the view transparency and returns a new color - The
RGB
andRGBf
methods families allow to create new colors from RGB(A) with the transparency already applied (wrappers aroundnvgRGB
functions)
Built-in fonts are stored in the FontStash
instance of Application
, as nanovg font IDs (to be used with nvgFontFaceId
). The stash instance is given as parameter of the draw()
method of each view.
Some views like Label
allow to change the font used for drawing, but you need to load them yourself using Application::loadFont
or Application::loadFontFromMemory
first.
There are currently three fonts in the stash:
-
material
: the Material Icons font -
sharedSymbols
: the Switch shared symbols font (only available on HOS) -
regular
: all of the above merged with the regular text font (shared font on HOS, InterUI on PC)
nanovg allows merging fonts (called font "fallbacks"), and this is what is happening with the regular font. That allows you to use the shared symbols and material seamlessly when drawing text using the regular font.
When drawing using the regular font, each glyph is looked up in the following order:
- Regular text font
- Shared symbols font
- Material Icons font
Unfortunately some glyphs are common for both Material Icons and shared symbols fonts. We decided to give priority to the shared symbols font since it contains fewer glyphs than Material Icons. You can use the material
font if you want to access all glyphs from Material Icons.