trait DrawRectangleTrait in Image Effects 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/ImageToolkit/Operation/DrawRectangleTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\DrawRectangleTrait
- 8 src/Plugin/ImageToolkit/Operation/DrawRectangleTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\DrawRectangleTrait
Base trait for draw rectangle operations.
Hierarchy
- trait \Drupal\image_effects\Plugin\ImageToolkit\Operation\DrawRectangleTrait
2 files declare their use of DrawRectangleTrait
- DrawRectangle.php in src/
Plugin/ ImageToolkit/ Operation/ gd/ DrawRectangle.php - DrawRectangle.php in src/
Plugin/ ImageToolkit/ Operation/ imagemagick/ DrawRectangle.php
File
- src/
Plugin/ ImageToolkit/ Operation/ DrawRectangleTrait.php, line 11
Namespace
Drupal\image_effects\Plugin\ImageToolkit\OperationView source
trait DrawRectangleTrait {
/**
* {@inheritdoc}
*/
protected function arguments() {
return [
'rectangle' => [
'description' => 'A PositionedRectangle object.',
],
'fill_color' => [
'description' => 'The RGBA color of the polygon fill.',
'required' => FALSE,
'default' => NULL,
],
'fill_color_luma' => [
'description' => 'If TRUE, convert RGBA of the polygon fill to best match using luma.',
'required' => FALSE,
'default' => FALSE,
],
'border_color' => [
'description' => 'The RGBA color of the polygon line.',
'required' => FALSE,
'default' => NULL,
],
'border_color_luma' => [
'description' => 'If TRUE, convert RGBA of the polygon line to best match using luma.',
'required' => FALSE,
'default' => FALSE,
],
];
}
/**
* {@inheritdoc}
*/
protected function validateArguments(array $arguments) {
// Ensure 'rectangle' is an expected PositionedRectangle object.
if (!$arguments['rectangle'] instanceof PositionedRectangle) {
throw new \InvalidArgumentException("PositionedRectangle passed to the 'draw_rectangle' operation is invalid");
}
// Match color luma.
if ($arguments['fill_color'] && $arguments['fill_color_luma']) {
$arguments['fill_color'] = ColorUtility::matchLuma($arguments['fill_color']);
}
if ($arguments['border_color'] && $arguments['border_color_luma']) {
$arguments['border_color'] = ColorUtility::matchLuma($arguments['border_color']);
}
return $arguments;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrawRectangleTrait:: |
protected | function | ||
DrawRectangleTrait:: |
protected | function |