Skip to content

Commit

Permalink
spin: Add spin rotations option
Browse files Browse the repository at this point in the history
This option sets the number of spin rotations. Negative values will
reverse the direction.
  • Loading branch information
soreau committed Aug 27, 2024
1 parent 3a9402d commit 8a04f18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions metadata/animate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,10 @@
<_long>Sets the duration for the spin animation in milliseconds.</_long>
<default>250ms linear</default>
</option>
<option name="spin_rotations" type="int">
<_short>Spin rotations</_short>
<_long>Number of rotations for the spin animation. Negative values reverse the spin direction.</_long>
<default>1</default>
</option>
</plugin>
</wayfire>
3 changes: 2 additions & 1 deletion plugins/animate/spin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


wf::option_wrapper_t<wf::animation_description_t> spin_duration{"animate/spin_duration"};
wf::option_wrapper_t<int> spin_rotations{"animate/spin_rotations"};

namespace wf
{
Expand Down Expand Up @@ -77,7 +78,7 @@ class spin_animation : public animation_base
->get_transformer<wf::scene::view_2d_transformer_t>(spin_transformer_name);
auto progress = this->progression.progress();
transform->alpha = progress;
transform->angle = progress * M_PI * 4.0;
transform->angle = progress * M_PI * 2.0 * int(spin_rotations);
transform->scale_x = 0.01 + progress * 0.99;
transform->scale_y = 0.01 + progress * 0.99;

Expand Down

0 comments on commit 8a04f18

Please sign in to comment.