35 lines
1 KiB
PHP
35 lines
1 KiB
PHP
<?php
|
|
|
|
namespace swf2ass\ass;
|
|
|
|
use swf2ass\Constants;
|
|
use swf2ass\MatrixTransform;
|
|
use swf2ass\StyleRecord;
|
|
use swf2ass\Vector2;
|
|
|
|
class positionTag implements ASSPositioningTag {
|
|
|
|
private Vector2 $position;
|
|
|
|
public function __construct(Vector2 $position) {
|
|
$this->position = $position;
|
|
}
|
|
|
|
public function transitionMatrixTransform(MatrixTransform $transform): ?positionTag {
|
|
$translation = $transform->getTranslation()->divide(Constants::TWIP_SIZE);
|
|
return $this->position->equals($translation) ? self::fromMatrixTransform($transform) : null;
|
|
}
|
|
|
|
public function encode(): string {
|
|
return "\\pos({$this->position->x},{$this->position->y})";
|
|
}
|
|
|
|
public function equals(ASSTag $tag): bool {
|
|
return $tag instanceof $this and $this->position->equals($tag->position);
|
|
}
|
|
|
|
public static function fromMatrixTransform(MatrixTransform $transform): ?positionTag {
|
|
$translation = $transform->getTranslation()->divide(Constants::TWIP_SIZE);
|
|
return new positionTag($translation);
|
|
}
|
|
} |