// Copyright © SixtyFPS GmbH // SPDX-License-Identifier: MIT import { DialState } from "dial.slint"; import { Palette } from "../../common.slint"; export component Light { function pulseAnimation(duration: duration) -> float { return 1 * (1 - abs(sin(360deg * animation-tick() / duration))); } in property index; in property volume; property gap: (360deg - (DialState.startAngle - DialState.endAngle)) / DialState.totalLights; property angle: (index * gap) + DialState.startAngle; property lightOn: index <= volume; property pulse: index == 0 && lightOn && volume <= 1 ? pulseAnimation(5s) : 1.0; x: DialState.elementRadius * angle.cos(); y: DialState.elementRadius * angle.sin(); width: 0; height: 0; states [ lightOff when !root.lightOn: { dialLed.opacity: 0; } lightOn when root.lightOn: { dialLed.opacity: pulse; in { animate dialLed.opacity { duration: 100ms; easing: ease-in-sine; } } out { animate dialLed.opacity { duration: 600ms; easing: ease-out-sine; } } } ] Rectangle { Rectangle { width: 10px; height: self.width; border-radius: self.width / 2; background: Palette.door-light-off; opacity: 0.1; } dialLed := Image { source: Palette.dark-color-scheme ? @image-url("../../images/led-dark.png") : @image-url("../../images/led.png"); } } } export component DialLights { width: 425px; height: 427px; in property volume; Rectangle { width: 1px; height: 1px; x: 212px; y: 210px; lightHolder := Rectangle { x: 0px; y: 2px; for i in DialState.totalLights + 1: Light { index: i; volume: root.volume; } } } }