add trig
This commit is contained in:
parent
ef8ea67114
commit
6631c74e22
|
@ -6,12 +6,20 @@ enum Prop
|
||||||
{
|
{
|
||||||
case LINEAR;
|
case LINEAR;
|
||||||
case WAVE;
|
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
|
public function calculatorCallback(): callable
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
static::LINEAR => fn ($i, $height) => $i / $height,
|
static::LINEAR => fn ($i, $height) => $i / $height,
|
||||||
static::WAVE => fn ($i, $height) => abs(($i / $height) - 0.5),
|
static::WAVE => fn ($i, $height) => abs(($i / $height) - 0.5),
|
||||||
|
static::TRIG => fn ($i, $height) => (cos(2 * pi() * $i / $height) + 1) / 2,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue