You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB
PHP

<?php
namespace Cijber\GraphicsToolkit;
use Cijber\GraphicsToolkit\Consts\CairoConsts;
use FFI;
/**
* @method static FFI\CData create(FFI\CData $surface)
* @method static FFI\CData image_surface_create(int $format, int $width, int $height)
* @method static FFI\CData image_surface_create_for_data(FFI\CData $data, int $format, int $width, int $height, int $stride)
* @method static int format_stride_for_width(int $format, int $width)
* @method static void show_text(FFI\CData $cr, string $text)
* @method static void surface_flush(FFI\CData $surface)
*/
class Cairo extends CairoConsts {
private static FFI $ffi;
private static bool $started = false;
static function init() {
if (static::$started) {
return;
}
static::$ffi = FFI::load(__DIR__ . "/../headers/cairo.h");
static::$started = true;
}
static function __callStatic($name, $arguments) {
if ( ! static::$started) {
static::init();
}
return static::$ffi->{"cairo_" . $name}(...$arguments);
}
}