In my glance view, I typically use the following pattern in onUpdate
:
onUpdate( dc as Dc ) as Void {
dc.setColor( Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT );
dc.clear();
// draw some stuff
}
This clears the previous frame using a transparent background and redraws the content. Using a transparent background allows the underlying gradients or graphics that Garmin applies to glance backgrounds on some devices to remain visible.
However, I've run into an issue when handling drawing errors.
If an error occurs during rendering, I’d like to clear the canvas again and display a warning instead. The logic looks like this:
onUpdate( dc as Dc ) as Void {
dc.setColor( Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT );
dc.clear();
// draw some stuff
dc.setColor( Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT );
dc.clear();
// draw some other stuff
}
Here’s the problem: while the first dc.clear()
works as expected and clears the previous frame, the second dc.clear()
—which is meant to clear the failed rendering—doesn’t fully clear the display. It seems that using Graphics.COLOR_TRANSPARENT
a second time causes the canvas to behave as if it’s layering transparency, letting prior content “bleed through.”. Or, bluntly put, the second dc.clear() does nothing at all.
The only workaround I’ve found is to use Graphics.COLOR_BLACK
instead of transparent for the second clear. Unfortunately, this removes any background gradients or images, which breaks the intended visual design.
What do you guys think, bug or feature?