Skip to content

Commit

Permalink
helix: Add rotations and strip height options
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau committed Aug 28, 2024
1 parent e404d0e commit edc449e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 12 additions & 0 deletions metadata/animate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,17 @@
<_long>Sets the duration for the helix animation in milliseconds.</_long>
<default>250ms linear</default>
</option>
<option name="helix_rotations" type="int">
<_short>Helix rotations</_short>
<_long>Number of rotations for the helix animation.</_long>
<default>1</default>
<min>1</min>
</option>
<option name="helix_strip_height" type="int">
<_short>Helix strip height</_short>
<_long>Height of each helix strip in pixels.</_long>
<default>20</default>
<min>10</min>
</option>
</plugin>
</wayfire>
12 changes: 7 additions & 5 deletions plugins/animate/helix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@


wf::option_wrapper_t<wf::animation_description_t> helix_duration{"animate/helix_duration"};
wf::option_wrapper_t<int> helix_strip_height{"animate/helix_strip_height"};
wf::option_wrapper_t<int> helix_rotations{"animate/helix_rotations"};

static const char *helix_vert_source =
R"(
Expand Down Expand Up @@ -140,9 +142,8 @@ class helix_transformer : public wf::scene::view_2d_transformer_t
auto src_tex = wf::scene::transformer_render_instance_t<helix_transformer>::get_texture(1.0);
auto progress = self->progression.progress();
auto og = self->animation_geometry;
self->animation_geometry = og;

int line_height = 20;
int line_height = int(helix_strip_height);
std::vector<float> uv;
std::vector<float> vertices;
glm::mat4 l = glm::lookAt(
Expand Down Expand Up @@ -171,10 +172,11 @@ class helix_transformer : public wf::scene::view_2d_transformer_t
m = glm::rotate(m, float(M_PI), glm::vec3(1.0, 0.0, 0.0));
m =
glm::rotate(m,
float(std::min(M_PI * 2.0,
float(std::min(M_PI * int(helix_rotations),
std::max(0.0,
(M_PI * 3.5 * (1.0 - progress)) - M_PI * 2.0 * (float(i) / src_box.height)) +
M_PI / 2.0)), glm::vec3(0.0, 1.0, 0.0));
((M_PI * 1.5 + int(helix_rotations) * M_PI) * (1.0 - progress)) - M_PI * 2.0 *
(float(i) / src_box.height)) +
M_PI / 2.0) - int(helix_rotations) * M_PI), glm::vec3(0.0, 1.0, 0.0));
m = glm::scale(m, glm::vec3(2.0f / og.width, 2.0f / og.height, 1.0));
auto x1 = src_box.width / 2.0;
auto x2 = -(src_box.width / 2.0);
Expand Down

0 comments on commit edc449e

Please sign in to comment.