Getting background colour & force redrawing background

I want to fill layer bezierpath in the current background colour (black if in dark mode, and custom colour if present in master). Is there a simple way to obtain & set the fill colour?

Also, I am making a plugin with vanilla window, and want any change in UI to call background() and inactiveLayerForeground() automatically. I think I should add an observer, or find a way to send a layer parameter to them in the UI function, and I don’t know quite how to do either of them.

You can tell the current graphics view to redraw like so:

if tab := Font.currentTab:
    tab.graphicView().redraw()

You can get the background color like so:

from AppKit import NSColor
cgColor = Font.currentTab.graphicView().layer().backgroundColor()
color = NSColor.colorWithCGColor_(cgColor)

You can get the color from the

graphicView = self.controller.graphicView()
backgroundColor = graphicView.canvasColor()
foregroundColor = graphicView.foregroundColor()