bzflag-rendering.php: Generating map thumbnails in PHP

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

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.

random_map.png
(29.12 KiB) Not downloaded yet
hix.png
(14.86 KiB) Not downloaded yet
dupi.png
(30.84 KiB) Not downloaded yet
pillbox.png
(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);
$renderer->writeToFile("my_world.png");

// Export as an SVG
$renderer = new SVGWorldRenderer($world);
$renderer->writeToFile("my_world.svg");
Github: allejo/bzflag-rendering.php
User avatar
allejo
Breaker of Builds
Breaker of Builds
Posts: 809
Joined: Sun Feb 17, 2008 10:01 pm
Location: /dev/null
Contact:

Re: bzflag-rendering.php: Generating map thumbnails in PHP

Post by allejo »

Happy Easter! We may not have a resident bunny delivering eggs but we do have gep delivering mesh support to this library! This library can now draw meshes in radar thumbnails! 🥳

unknown_mini.png
(53.03 KiB) Not downloaded yet
Post Reply