diff options
Diffstat (limited to 'www/wiki/extensions/Maps/src/Elements/BaseFillableElement.php')
-rw-r--r-- | www/wiki/extensions/Maps/src/Elements/BaseFillableElement.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/www/wiki/extensions/Maps/src/Elements/BaseFillableElement.php b/www/wiki/extensions/Maps/src/Elements/BaseFillableElement.php new file mode 100644 index 00000000..cf740fc8 --- /dev/null +++ b/www/wiki/extensions/Maps/src/Elements/BaseFillableElement.php @@ -0,0 +1,45 @@ +<?php + +namespace Maps\Elements; + +/** + * @since 2.0 + */ +class BaseFillableElement extends BaseStrokableElement { + + protected $fillColor; + protected $fillOpacity; + + public function getJSONObject( string $defText = '', string $defTitle = '' ): array { + $parentArray = parent::getJSONObject( $defText, $defTitle ); + $array = [ + 'fillColor' => $this->hasFillColor() ? $this->getFillColor() : '#FF0000', + 'fillOpacity' => $this->hasFillOpacity() ? $this->getFillOpacity() : '0.5', + ]; + return array_merge( $parentArray, $array ); + } + + public function hasFillColor() { + return !is_null( $this->fillColor ) && $this->fillColor !== ''; + } + + public function getFillColor() { + return $this->fillColor; + } + + public function setFillColor( $fillColor ) { + $this->fillColor = trim( $fillColor ); + } + + public function hasFillOpacity() { + return !is_null( $this->fillOpacity ) && $this->fillOpacity !== ''; + } + + public function getFillOpacity() { + return $this->fillOpacity; + } + + public function setFillOpacity( $fillOpacity ) { + $this->fillOpacity = trim( $fillOpacity ); + } +} |