diff --git a/src/Prop.php b/src/Prop.php index dbb59fe..3882e0c 100644 --- a/src/Prop.php +++ b/src/Prop.php @@ -6,12 +6,20 @@ enum Prop { case LINEAR; case WAVE; + case TRIG; + /** + * Function for final color calculation. + * $i is the position of the line which is drawn in pixels. This can be between 0 and the image height. + * $height is the full height of the image. + * Return value should be between 0 and 1. + */ public function calculatorCallback(): callable { return match ($this) { static::LINEAR => fn ($i, $height) => $i / $height, static::WAVE => fn ($i, $height) => abs(($i / $height) - 0.5), + static::TRIG => fn ($i, $height) => (cos(2 * pi() * $i / $height) + 1) / 2, }; } }