32 lines
961 B
PHP
32 lines
961 B
PHP
<?php
|
|
|
|
namespace swf2ass;
|
|
|
|
class LinearGradient implements Gradient {
|
|
/** @var GradientItem[] */
|
|
public $colors;
|
|
/** @var MatrixTransform|null */
|
|
public ?MatrixTransform $transform;
|
|
|
|
public function __construct($colors = [], MatrixTransform $transform = null) {
|
|
$this->colors = $colors;
|
|
$this->transform = $transform;
|
|
}
|
|
|
|
public function getItems(): array {
|
|
return $this->colors;
|
|
}
|
|
|
|
public function getMatrixTransform(): ?MatrixTransform {
|
|
return $this->transform;
|
|
}
|
|
|
|
public static function fromXML(\DOMElement $element): LinearGradient {
|
|
$colors = [];
|
|
foreach ($element->getElementsByTagName("GradientItem") as $item) {
|
|
$colors[] = GradientItem::fromXML($item);
|
|
}
|
|
$matrix = $element->getElementsByTagName("matrix");
|
|
return new LinearGradient($colors, $matrix->count() > 0 ? MatrixTransform::fromXML($matrix->item(0)) : null);
|
|
}
|
|
} |