swf2ass/src/ass/lineColorTag.php

24 lines
992 B
PHP

<?php
namespace swf2ass\ass;
use swf2ass\Color;
use swf2ass\FillStyleRecord;
use swf2ass\LineStyleRecord;
use swf2ass\StyleRecord;
use swf2ass\Utils;
class lineColorTag extends colorTag {
public static function fromStyleRecord(StyleRecord $record): ?lineColorTag {
if ($record instanceof LineStyleRecord) {
return new lineColorTag($record->color, $record->color);
}else if ($record instanceof FillStyleRecord and $record->border !== null){
return new lineColorTag($record->border->color, $record->border->color);
}
return new lineColorTag(null, null);
}
public function encode(ASSEventTime $event): string {
return $this->color === null ? "\\3a&HFF&" : ("\\3c&H" . strtoupper(Utils::padHex(dechex($this->color->b))) . strtoupper(Utils::padHex(dechex($this->color->g))) . strtoupper(Utils::padHex(dechex($this->color->r))) . "&\\3a&H" . strtoupper(Utils::padHex(dechex(255 - $this->color->alpha))) . "&");
}
}