paintStudioFocusLight function
void
paintStudioFocusLight(
- Canvas canvas,
- RRect outline,
- Color focus,
- StudioLight light, {
- bool inside = false,
Paints Studio's keyboard focus round outline on canvas: the edge lit
in focus, StudioMetrics.focusWidth of it hugging the outline with no
gap, and a soft glow of the indicator's amber beyond it, as lit studio
gear shows it. Nothing lights inside the outline, so the face and its
words are untouched. A key inside a bank stands in its socket with no
room round it: its edge lights just inside its own outline, the glow
inward, so nothing spills on its neighbours. focus's alpha fades the
whole light.
Implementation
void paintStudioFocusLight(
Canvas canvas,
RRect outline,
Color focus,
StudioLight light, {
bool inside = false,
}) {
if (focus.a == 0) return;
final night = light.colors.brightness == Brightness.dark;
const w = StudioMetrics.focusWidth;
final glow = Paint()
..color = light.colors.indicator.withValues(
alpha: focus.a * (night ? 0.55 : 0.7),
)
..maskFilter = MaskFilter.blur(
inside ? BlurStyle.inner : BlurStyle.outer,
inside ? 4 : 6,
);
final edge = Paint()
..style = PaintingStyle.stroke
..strokeWidth = w
..color = focus;
if (inside) {
canvas
..save()
..clipRRect(outline)
..drawRRect(outline, glow)
..drawRRect(outline.deflate(w / 2), edge)
..restore();
} else {
canvas
..drawRRect(outline, glow)
..drawRRect(outline.inflate(w / 2), edge);
}
}