65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace swf2ass;
|
|
|
|
class CubicSplineCurveRecord implements Record {
|
|
public Vector2 $start;
|
|
/** @var Vector2[] */
|
|
public array $control;
|
|
public Vector2 $anchor;
|
|
|
|
/**
|
|
* @param Vector2[] $control
|
|
* @param Vector2 $anchor
|
|
* @param Vector2 $start
|
|
*/
|
|
public function __construct(array $control, Vector2 $anchor, Vector2 $start) {
|
|
$this->control = $control;
|
|
$this->anchor = $anchor;
|
|
$this->start = $start;
|
|
}
|
|
|
|
public function getStart(): Vector2 {
|
|
return $this->start;
|
|
}
|
|
|
|
public function getEnd(): Vector2 {
|
|
return $this->anchor;
|
|
}
|
|
|
|
public function reverse(): CubicSplineCurveRecord {
|
|
return new CubicSplineCurveRecord(array_reverse($this->control), $this->start, $this->anchor);
|
|
}
|
|
|
|
public function applyMatrixTransform(MatrixTransform $transform, bool $applyTranslation = true): CubicSplineCurveRecord {
|
|
$control = [];
|
|
foreach ($this->control as $c) {
|
|
$control[] = $transform->applyToVector($c, $applyTranslation);
|
|
}
|
|
|
|
return new CubicSplineCurveRecord($control, $transform->applyToVector($this->anchor, $applyTranslation), $transform->applyToVector($this->start, $applyTranslation));
|
|
}
|
|
|
|
|
|
|
|
public function equals(Record $other): bool {
|
|
if($other instanceof $this and count($this->control) === count($other->control)){
|
|
foreach ($this->control as $i => $c) {
|
|
if(!$c->equals($other[$i])){
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return $this->start->equals($other->start) and $this->anchor->equals($other->anchor);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function append(Record $record): ?CubicSplineCurveRecord {
|
|
if ($record instanceof CubicCurveRecord) {
|
|
|
|
}
|
|
|
|
return null;
|
|
}
|
|
} |