65 lines
2 KiB
PHP
65 lines
2 KiB
PHP
<?php
|
|
|
|
namespace swf2ass\ass;
|
|
|
|
use swf2ass\MatrixTransform;
|
|
|
|
class matrixTransformTag implements ASSPositioningTag {
|
|
|
|
private ?scaleTag $scale = null;
|
|
private ?rotationTag $rotation = null;
|
|
private ?shearingTag $shear = null;
|
|
private ?positionTag $position = null;
|
|
|
|
public function __construct() {
|
|
|
|
}
|
|
|
|
public function transitionMatrixTransform(MatrixTransform $transform): ?matrixTransformTag {
|
|
if ($this->position !== null and $this->position->transitionMatrixTransform($transform) === null) {
|
|
return null;
|
|
}
|
|
if ($this->scale !== null and $this->scale->transitionMatrixTransform($transform) === null) {
|
|
return null;
|
|
}
|
|
if ($this->rotation !== null and $this->rotation->transitionMatrixTransform($transform) === null) {
|
|
return null;
|
|
}
|
|
if ($this->shear !== null and $this->shear->transitionMatrixTransform($transform) === null) {
|
|
return null;
|
|
}
|
|
|
|
return self::fromMatrixTransform($transform);
|
|
}
|
|
|
|
public function encode(): string {
|
|
$tag = "";
|
|
if ($this->scale !== null) {
|
|
$tag .= $this->scale->encode();
|
|
}
|
|
if ($this->rotation !== null) {
|
|
$tag .= $this->rotation->encode();
|
|
}
|
|
if ($this->shear !== null) {
|
|
$tag .= $this->shear->encode();
|
|
}
|
|
if ($this->position !== null) {
|
|
$tag .= $this->position->encode();
|
|
}
|
|
return $tag;
|
|
}
|
|
|
|
public function equals(ASSTag $tag): bool {
|
|
return $tag instanceof $this and $this->position->equals($tag->position);
|
|
}
|
|
|
|
public static function fromMatrixTransform(MatrixTransform $transform): ?matrixTransformTag {
|
|
$tag = new matrixTransformTag();
|
|
$tag->scale = scaleTag::fromMatrixTransform($transform);
|
|
$tag->rotation = rotationTag::fromMatrixTransform($transform);
|
|
$tag->shear = shearingTag::fromMatrixTransform($transform);
|
|
$tag->position = positionTag::fromMatrixTransform($transform);
|
|
|
|
return $tag;
|
|
}
|
|
} |