swf2ass/src/ass/borderTag.php

36 lines
892 B
PHP

<?php
namespace swf2ass\ass;
use swf2ass\Constants;
use swf2ass\LineStyleRecord;
use swf2ass\StyleRecord;
class borderTag implements ASSStyleTag {
/** @var int|float */
private $size;
public function __construct($size = 0) {
$this->size = $size;
}
public function transitionStyleRecord(StyleRecord $record): ?borderTag {
return self::fromStyleRecord($record);
}
public function encode(): string {
return "\\bord{$this->size}";
}
public static function fromStyleRecord(StyleRecord $record): ?borderTag {
if ($record instanceof LineStyleRecord) {
return new borderTag($record->width / Constants::TWIP_SIZE);
}
return new borderTag();
}
public function equals(ASSTag $tag): bool {
return $tag instanceof $this and abs($this->size - $tag->size) <= Constants::EPSILON;
}
}