remove animatedSides, use frameAnimation

This commit is contained in:
darksignal7
2025-10-05 21:33:19 +03:00
parent 33fdc1cdc7
commit f885351464
@@ -7,8 +7,7 @@ import qs.modules.common
Item {
id: root
property int sides: 12
property real animatedSides: 12
property int sides: 12
property int implicitSize: 100
property real amplitude: implicitSize / 50
property int renderPoints: 360
@@ -19,25 +18,19 @@ Item {
implicitWidth: implicitSize
implicitHeight: implicitSize
property real waveTime: 0
property real shapeRotation: 0
Loader{
active: constantlyRotate
sourceComponent: Timer{
interval: 16 // Does it effect performance, probably, is it noticeable, not really
running: true; repeat: true
sourceComponent: FrameAnimation{
running: true
onTriggered: {
root.waveTime += 0.05
shapeRotation += 0.05
}
}
}
onSidesChanged: NumberAnimation {
target: root
property: "animatedSides"
to: root.sides
duration: 100
easing.type: Easing.InOutQuad
}
Shape {
id: shape
@@ -59,7 +52,7 @@ Item {
var radius = root.implicitSize / 2 - root.amplitude
for (var i = 0; i <= steps; i++) {
var angle = (i / steps) * 2 * Math.PI
var wave = constantlyRotate ? Math.sin(angle * root.animatedSides + Math.PI/2 - root.waveTime) * root.amplitude : Math.sin(angle * root.animatedSides + Math.PI/2) * root.amplitude
var wave = constantlyRotate ? Math.sin(angle * root.sides + Math.PI/2 - root.shapeRotation) * root.amplitude : Math.sin(angle * root.shapeRotation + Math.PI/2) * root.amplitude
var x = Math.cos(angle) * (radius + wave) + cx
var y = Math.sin(angle) * (radius + wave) + cy
points.push(Qt.point(x, y))