You are here

protected static function GdGaussianBlur::reflect in Image Effects 8.3

Same name and namespace in other branches
  1. 8 src/Component/GdGaussianBlur.php \Drupal\image_effects\Component\GdGaussianBlur::reflect()
  2. 8.2 src/Component/GdGaussianBlur.php \Drupal\image_effects\Component\GdGaussianBlur::reflect()

Ensures that a value is in the 0-max range.

If out of bounds, returns the reflected value within the range.

Parameters

int $max: The maximum value.

int $x: The value to be checked.

Return value

int The input value if in-bounds, otherwise the reflected value within the range.

1 call to GdGaussianBlur::reflect()
GdGaussianBlur::applyCoeffsLine in src/Component/GdGaussianBlur.php
Applies the Gaussian coefficients to a line of the destination image.

File

src/Component/GdGaussianBlur.php, line 148

Class

GdGaussianBlur
Gaussian Blur helper methods for GD.

Namespace

Drupal\image_effects\Component

Code

protected static function reflect($max, $x) {
  if ($x < 0) {
    return -$x;
  }
  if ($x >= $max) {
    return $max - ($x - $max) - 1;
  }
  return $x;
}