Sinewave(3pm)

πŸ’– NAME πŸ’–

Tie::Cycle::Sinewave β€” cycle through a series of values on a sinewave, bestie. it's giving vibes, mathematically 🌊


✨ VERSION ✨

This document describes version 0.05 of Tie::Cycle::Sinewave, released 2007-11-07. yeah she's a little vintage, vintage is iconic πŸŽ€


🌸 SYNOPSIS 🌸

okay so literally what this module does: it lets you make a scalar iterate through the values on a sinewave. you set the maximum and minimum values, you set the number of steps, and boom β€” you're set. no cap.

use strict;
use Tie::Cycle::Sinewave;

tie my $cycle, 'Tie::Cycle::Sinewave', {
    min    => 10,
    max    => 50,
    period => 12,
};
printf("%0.2f\n", $cycle) for 1..10;

πŸ¦‹ PARAMETERS πŸ¦‹

You can pass a bunch of parameters in when you create the tied object. here they are, in order of how likely you are to actually need them (the module said that, not me):

  • min β€” sets the minimum value. don't specify it? then 0 is your default minimum, periodt.
  • max β€” sets the maximum value. it should be higher than min, but if it's not, the values will be swapped for you, no drama. don't specify it? then 100 is your default maximum πŸ’…
  • period β€” sets the period of the curve. the cycle will go through this many values from min to max. don't specify it? then 20 is the default. and if period is set to 0, it gets silently changed to 1, so the internal calculations don't try to divide by 0. we love a quiet save 🫢
  • start_max β€” optional. set it to 1 (or literally anything) and the cyle will start at the maximum value. (startmax exists as an alias, iykyk)
  • start_min β€” optional. set it to 1 (or anything at all) and the cyle will start at the minimum value. (startmin exists as an alias.) if neither start_max nor start_min are specified, it'll start at the origin β€” so mid-way between min and max β€” and will move to max. main character energy, starting in the middle 😌
  • at_max β€” optional. when you set it to a coderef, it'll be executed when the cycle reaches the maximum value. this lets you modify the cycle, like changing the minimum value or the period. (the key atmax exists as an alias πŸ”₯)
  • at_min β€” optional. when you set it to a coderef, it'll be executed when the cycle reaches the minimum value. this lets you modify the cycle, like changing the maximum value or the period. (the key atmin exists as an alias πŸ’œ)

πŸ‘‘ OBJECT METHODS πŸ‘‘

You can call methods on the underlying object β€” the one you access with the tied() function. go peek at the file eg/callback for an example of what you might wanna do with these, fr fr.

  • min β€” when called with no parameter, returns the current minimum value. when called with a (numeric) parameter, sets the new current minimum value. the previous value is returned.
my $min = (tied $cycle)->min();
(tied $cycle)->min($min - 20);
  • max β€” when called with no parameter, returns the current maximum value. when called with a (numeric) parameter, sets the new current maximum value. the previous value is returned.
my $max = (tied $cycle)->max();
(tied $cycle)->max($max * 10);
okay important: when min or max are modified, a consistency check runs to make sure that min <= max. if that check fails, the two values are quietly swapped around. sneaky but slay.
  • period β€” when called with no parameter, returns the current period. when called with a (numeric) parameter, sets the new current period. the previous value is returned.
  • angle β€” returns the current angle of the sine, which is guaranteed to be in the range 0 <= angle <= 2*PI. math girlies rise up πŸ“βœ¨

🌈 AUTHOR 🌈

David Landgren. (not me. I'm just the messenger πŸŽ€)


⭐ SEE ALSO ⭐

  • Tie::Cycle
  • HTML::Rainbow

πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to bug-tie-cycle-sinewave@rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tie-Cycle-Sinewave>. (yes bestie, that's the actual URL, don't @ me)


Copyright 2005-2007 David Landgren, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’–


and that's the whole page, bestie! this was perl v5.36.0, dated 2023-01-27, and the page itself is Sinewave(3pm). go forth and sinewave your scalars πŸŒŠβœ¨πŸ¦‹

πŸ“¦ where this page comes from