swf2ass/src/ass/lineColorTag.php

21 lines
726 B
PHP

<?php
namespace swf2ass\ass;
use swf2ass\Color;
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);
}
return new lineColorTag(new Color(0, 0, 0, 255));
}
public function encode(): string {
return "\\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($this->color->alpha))) . "&";
}
}