swf2ass/src/ass/rotationTag.php

36 lines
987 B
PHP

<?php
namespace swf2ass\ass;
use swf2ass\Constants;
use swf2ass\MatrixTransform;
use swf2ass\StyleRecord;
use swf2ass\Vector2;
class rotationTag implements ASSPositioningTag {
private Vector2 $rotate;
public function __construct(Vector2 $rotate) {
$this->rotate = $rotate;
}
public function transitionMatrixTransform(MatrixTransform $transform): ?rotationTag {
return self::fromMatrixTransform($transform);
}
public function encode(): string {
return "\\frx{$this->rotate->x}\\fry{$this->rotate->y}";
}
public function equals(ASSTag $tag): bool {
return $tag instanceof $this and $this->rotate->equals($tag->rotate);
}
public static function fromMatrixTransform(MatrixTransform $transform): ?rotationTag {
$scale = $transform->getScale();
//$rotation = $transform->getRotateSkew(); ????
return new rotationTag(new Vector2($scale->y < 0 ? 180 : 0, $scale->x < 0 ? 180 : 0));
}
}