1. Go to this page and download the library: Download microscrap/metal-gfx library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
microscrap / metal-gfx example snippets
use ScrapyardIO\Tubes\Core\MagicAliases\Framebuffer;
use Microscrap\GFX\Metal\MetalHandledFramebuffer;
$buffer = Framebuffer::driver('metal')
->size(320, 240)
->format(MetalHandledFramebuffer::rgbaSpec())
->create();
$buffer->setPixel(10, 10, 0xFF0000FF);
use ScrapyardIO\Tubes\Core\MagicAliases\Window;
use Microscrap\GFX\Metal\MetalRenderer2D;
$window = Window::driver('metal')->title('Metal')->size(800, 600)->open();
$fb = $window->framebuffer(); // MetalHandledFramebuffer, not headless
$gfx = (new MetalRenderer2D)->setFramebuffer($fb);
$gfx->fill(0xFF203040)
->fillCircle(400, 300, 80, 0xE0E0E0FF)
->setTextColor(0xFFFFFFFF)
->setCursor(40, 40)
->print('Metal');
$window->present()->pollEvents();
$window->close();
bash
php -m | grep metal
composer g=tubes-framebuffers-metal
php workshop vendor:publish --tag=tubes-windows-metal
# or: php workshop install:gfx metal
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.