- Raise PHP requirement from ^8.2 to ^8.4 (parser requires 8.4) - New parser classes available: MacrosFileReader, LabelsFileReader, Macro, MacroLibrary, MacroCollection, Label, LabelLibrary - Add programmatic test fixtures for macros-sample.bin + labels-sample.bin - Fix ServiceAgendaItemFactory sort_order to auto-increment
41 lines
1 KiB
PHP
41 lines
1 KiB
PHP
<?php
|
|
|
|
require_once dirname(__DIR__, 2).'/vendor/autoload.php';
|
|
|
|
use Rv\Data\Action\Label;
|
|
use Rv\Data\Color;
|
|
use Rv\Data\ProLabelsDocument;
|
|
|
|
function makeColor(float $r, float $g, float $b, float $a = 1.0): Color
|
|
{
|
|
$color = new Color();
|
|
$color->setRed($r);
|
|
$color->setGreen($g);
|
|
$color->setBlue($b);
|
|
$color->setAlpha($a);
|
|
|
|
return $color;
|
|
}
|
|
|
|
$doc = new ProLabelsDocument();
|
|
|
|
$labels = [
|
|
['name' => 'Copyright', 'r' => 0.8, 'g' => 0.2, 'b' => 0.2],
|
|
['name' => 'Vers 1', 'r' => 0.2, 'g' => 0.6, 'b' => 0.9],
|
|
['name' => 'Refrain', 'r' => 0.9, 'g' => 0.7, 'b' => 0.1],
|
|
['name' => 'Brücke', 'r' => 0.5, 'g' => 0.1, 'b' => 0.8],
|
|
];
|
|
|
|
$labelObjects = [];
|
|
foreach ($labels as $data) {
|
|
$label = new Label();
|
|
$label->setText($data['name']);
|
|
$label->setColor(makeColor($data['r'], $data['g'], $data['b']));
|
|
$labelObjects[] = $label;
|
|
}
|
|
$doc->setLabels($labelObjects);
|
|
|
|
$output = $doc->serializeToString();
|
|
file_put_contents(__DIR__.'/labels-sample.bin', $output);
|
|
echo 'Written '.strlen($output).' bytes'.PHP_EOL;
|