35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace swf2ass;
|
|
|
|
class ShiftedRadialGradient implements Gradient {
|
|
/** @var GradientItem[] */
|
|
public $colors;
|
|
/** @var MatrixTransform|null */
|
|
public ?MatrixTransform $transform;
|
|
|
|
public array $attributes;
|
|
|
|
public function __construct($colors = [], MatrixTransform $transform = null, array $attributes = []) {
|
|
$this->colors = $colors;
|
|
$this->transform = $transform;
|
|
$this->attributes = $attributes;
|
|
}
|
|
|
|
public function getItems(): array {
|
|
return $this->colors;
|
|
}
|
|
|
|
public function getMatrixTransform(): ?MatrixTransform {
|
|
return $this->transform;
|
|
}
|
|
|
|
public static function fromXML(\DOMElement $element): ShiftedRadialGradient {
|
|
$colors = [];
|
|
foreach ($element->getElementsByTagName("GradientItem") as $item) {
|
|
$colors[] = GradientItem::fromXML($item);
|
|
}
|
|
$matrix = $element->getElementsByTagName("matrix");
|
|
return new ShiftedRadialGradient($colors, $matrix->count() > 0 ? MatrixTransform::fromXML($matrix->item(0)) : null, ["spreadMode" => $element->hasAttribute("spreadMode") ? $element->getAttribute("spreadMode") : null, "interpolationMode" => $element->hasAttribute("interpolationMode") ? $element->getAttribute("interpolationMode") : null, "shift" => $element->hasAttribute("shift") ? $element->getAttribute("shift") : null,]);
|
|
}
|
|
} |