slint/examples/orbit-animation/orbiter.slint
Olivier Goffart 3e94bd2167 Janitor: Remove trailing whitespaces from all files
`git grep -I -l -O'sed -i "s/[[:space:]]*$//"' -e ''`
2025-01-10 13:23:22 +01:00

40 lines
1.3 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
enum OrbiterState { front, back }
export component Orbiter {
in property <OrbiterState> state: OrbiterState.front;
in-out property source <=> img.source;
in-out property colorize <=> img.colorize;
in property <angle> orbit-rotation: 0deg;
in property <angle> offset: 45deg;
in property <length> radius: 220px;
property <angle> internal-rotation: orbit-rotation + offset;
in property <angle> orbit-attack: 180deg;
in property <length> ball-size: 60px;
property <length> zPos: sin(internal-rotation) * radius;
out property <float> scale: 0.3 + 0.7 * (zPos + radius) / (2 * radius);
property <bool> infront: internal-rotation.mod(360deg) < 180deg;
function isVisible() -> bool {
if (infront && state == OrbiterState.front) || (!infront && state == OrbiterState.back) {
return true;
} else {
return false;
}
}
visible: isVisible();
Rectangle {
x: cos(orbit-attack) * cos(internal-rotation) * radius;
y: sin(orbit-attack) * cos(internal-rotation) * radius;
img := Image {
width: root.ball-size * scale;
height: root.ball-size * scale;
source: @image-url("images/sphere-small.png");
}
}
}