This commit is contained in:
Philipp Lang 2022-11-22 10:11:39 +01:00
parent ef8ea67114
commit 6631c74e22
1 changed files with 8 additions and 0 deletions

View File

@ -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,
};
}
}