swf2ass/src/MoveRecord.php

37 lines
1.1 KiB
PHP

<?php
namespace swf2ass;
class MoveRecord implements Record {
public Vector2 $start;
public Vector2 $to;
public function __construct(Vector2 $to, Vector2 $start) {
$this->to = $to;
$this->start = $start;
}
public function getStart(): Vector2 {
return $this->start;
}
public function getEnd(): Vector2 {
return $this->to;
}
public function reverse(): MoveRecord {
return new MoveRecord($this->start, $this->to);
}
public static function fromArray(array $element, Vector2 $cursor): MoveRecord {
return new MoveRecord(new Vector2($element["moveDeltaX"], $element["moveDeltaY"]), $cursor);
}
public function applyMatrixTransform(MatrixTransform $transform, bool $applyTranslation = true): MoveRecord {
return new MoveRecord($transform->applyToVector($this->to, $applyTranslation), $transform->applyToVector($this->start, $applyTranslation));
}
public function equals(Record $other): bool {
return $other instanceof $this and $this->start->equals($other->start) and $this->to->equals($other->to);
}
}