bzflag-rendering.php: Generating map thumbnails in PHP

General talk about the map making process.
Post Reply
User avatar
Breaker of Builds
Breaker of Builds
Posts: 785
Joined: Sun Feb 17, 2008 10:01 pm
Location: /dev/null

bzflag-rendering.php: Generating map thumbnails in PHP

Post by allejo »

I'd like to introduce my latest work: rendering map thumbnails! Now, this isn't an original idea; PyBZFlag and blast's map thumbnail script have already accomplished this in the past. I'm here to share a new implementation of this feature thanks to some initial proof-of-concept work by ashvala.

Here are some examples of maps that were generated with my code.

(29.12 KiB) Not downloaded yet
(14.86 KiB) Not downloaded yet
(30.84 KiB) Not downloaded yet
(6.13 KiB) Not downloaded yet

Don't get your hopes up entirely! You cannot give this library a BZW file and have it generate a thumbnail for you. Not yet at least. This library requires you to give it your map as a WorldDatabase from the bzflag-networking.php library. I'll get around to writing a BZW parser eventually. Maybe. Help is welcome!

Right now, the only way of getting a WorldDatabase object is to get one that's embedded from a replay file; that's how I'm achieving map thumbnails in Postgame.

Code: Select all

use allejo\bzflag\graphics\PNG\Radar\WorldRenderer as PNGWorldRenderer;
use allejo\bzflag\graphics\SVG\Radar\WorldRenderer as SVGWorldRenderer;
use allejo\bzflag\replays\Replay;

$replay = new Replay('official-match.rec');
$world = $replay->getHeader()->getWorldDatabase();

// Export as a PNG
$renderer = new PNGWorldRenderer($world);

// Export as an SVG
$renderer = new SVGWorldRenderer($world);
Github: allejo/bzflag-rendering.php
Post Reply