36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace swf2ass;
|
|
|
|
class ShapeDefinition implements ObjectDefinition {
|
|
public int $id;
|
|
public Rectangle $bounds;
|
|
public DrawPathList $shapeList;
|
|
|
|
public function __construct(int $id, Rectangle $bounds, DrawPathList $shapes) {
|
|
$this->id = $id;
|
|
$this->bounds = $bounds;
|
|
$this->shapeList = $shapes;
|
|
}
|
|
|
|
public function getObjectId(): int {
|
|
return $this->id;
|
|
}
|
|
|
|
public function getShapeList(): DrawPathList {
|
|
return $this->shapeList;
|
|
}
|
|
|
|
static function fromXML(\DOMElement $element): ShapeDefinition {
|
|
$styles = StyleList::fromXML($element->getElementsByTagName("styles")->item(0)->getElementsByTagName("StyleList")->item(0));
|
|
//Utils::dump_element($element->getElementsByTagName("styles")->item(0));
|
|
|
|
$drawPathList = new DrawPathList([]);
|
|
foreach ($element->getElementsByTagName("shapes")->item(0)->childNodes as $node) {
|
|
if ($node instanceof \DOMElement and $node->nodeName === "Shape") {
|
|
$drawPathList = $drawPathList->merge(DrawPathList::fromXML($node, $styles));
|
|
}
|
|
}
|
|
return new ShapeDefinition((int)$element->getAttribute("objectID"), Rectangle::fromXML($element->getElementsByTagName("bounds")->item(0)->getElementsByTagName("Rectangle")->item(0)), $drawPathList);
|
|
}
|
|
} |