<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use ProPresenter\Parser\PresentationBundle;
use ProPresenter\Parser\ProBundleWriter;
use ProPresenter\Parser\ProFileGenerator;

$image = imagecreatetruecolor(200, 150);
$blue = imagecolorallocate($image, 30, 60, 180);
imagefill($image, 0, 0, $blue);
$white = imagecolorallocate($image, 255, 255, 255);
imagestring($image, 5, 10, 10, 'ProPresenter', $white);
$tmpPng = tempnam(sys_get_temp_dir(), 'testbild-') . '.png';
imagepng($image, $tmpPng);
$imageBytes = file_get_contents($tmpPng);
unlink($tmpPng);

$refDir = dirname(__DIR__, 2) . '/ref';
$mediaAbsPath = '/Users/thorsten/AI/propresenter/ref/Media/test-background.png';

$song = ProFileGenerator::generate(
    'TestBild',
    [
        [
            'name' => 'Verse 1',
            'color' => [0.0, 0.0, 0.0, 1.0],
            'slides' => [
                [
                    'media' => 'file://' . $mediaAbsPath,
                    'format' => 'png',
                ],
            ],
        ],
    ],
    [['name' => 'normal', 'groupNames' => ['Verse 1']]],
);

$bundle = new PresentationBundle($song, 'TestBild.pro', [$mediaAbsPath => $imageBytes]);
ProBundleWriter::write($bundle, $refDir . '/TestBild.probundle');
echo "TestBild.probundle written\n";
