You are here

protected function DrawRectangle::execute in Image Effects 8

Same name in this branch
  1. 8 src/Plugin/ImageToolkit/Operation/gd/DrawRectangle.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\DrawRectangle::execute()
  2. 8 src/Plugin/ImageToolkit/Operation/imagemagick/DrawRectangle.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\DrawRectangle::execute()
Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/gd/DrawRectangle.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\DrawRectangle::execute()
  2. 8.2 src/Plugin/ImageToolkit/Operation/gd/DrawRectangle.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\DrawRectangle::execute()

Performs the actual manipulation on the image.

Image toolkit operation implementers must implement this method. This method is responsible for actually performing the operation on the image. When this method gets called, the implementer may assume all arguments, also the optional ones, to be available, validated and corrected.

Parameters

array $arguments: An associative array of arguments to be used by the toolkit operation.

Return value

bool TRUE if the operation was performed successfully, FALSE otherwise.

Overrides ImageToolkitOperationBase::execute

File

src/Plugin/ImageToolkit/Operation/gd/DrawRectangle.php, line 27

Class

DrawRectangle
Defines GD2 draw rectangle operation.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation\gd

Code

protected function execute(array $arguments) {
  $success = TRUE;
  if ($arguments['fill_color']) {
    $color = $this
      ->allocateColorFromRgba($arguments['fill_color']);
    $success = imagefilledpolygon($this
      ->getToolkit()
      ->getResource(), $this
      ->getRectangleCorners($arguments['rectangle']), 4, $color);
  }
  if ($success && $arguments['border_color']) {
    $color = $this
      ->allocateColorFromRgba($arguments['border_color']);
    $success = imagepolygon($this
      ->getToolkit()
      ->getResource(), $this
      ->getRectangleCorners($arguments['rectangle']), 4, $color);
  }
  return $success;
}