Download the PHP package cosmicpe/maprender without Composer
On this page you can find all versions of the php package cosmicpe/maprender. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cosmicpe/maprender
More information about cosmicpe/maprender
Files in cosmicpe/maprender
Package maprender
Short Description PocketMine-MP library to render regions in worlds as a 2D topographic map
License GPL-3.0-only
Informations about the package maprender
MapRender
A library for rendering a topographic view of sections within a world in PocketMine-MP.
Features
- Vibrant color palette spanning 800+ blocks
- Represent translucent blocks
- Elevation detail using shadows
- Render asynchronously
Usage
MapRender uses SOF3/await-generator to perform rendering asynchronously. A
MapRender instance may be initialized once and reused. MapRender is stateless, meaning you may invoke MapRender::render()
concurrently. render() returns a GdImage which gives you the ability to export the image as needed, or perhaps further
preprocess the image. See examples for a few ways you can use this. Coordinate parameters $x1, $x2,
$z1, and $z2 are chunk coordinates (not to be confused with block coordinates).
If you are unfamiliar with await-generator and are looking for a quick setup, use Await::f2c() to make a callback wrapper.
Examples
If you are working with block coordinates, use Chunk::COORD_BIT_SIZE to infer chunk coordinates. The example below
renders a 176x176 image (((radius x 2) + 1) * 16) where the center chunk is the spawn chunk of the default world.
If you are looking to transport data and hence need to export map image as raw PNG bytes, pass an in-memory stream instead of a file path.
By default, every block is represented as a 1x1 pixel. This means a map spanning 5x5 chunks has a resolution of 80x80.
You can use imagescale() to rescale the image. The example below scales the image by 4x (meaning each block is
represented using 4x4 pixels).
MapRender has default performance settings to ensure server load is kept minimum and at the same time maps render as quickly as possible. If these settings do not suit your server hardware, tweak them by creating a custom MapRender.
Sample rendered output
All versions of maprender with dependencies
pocketmine/pocketmine-mp Version ^5.0.0
sof3/await-generator Version ^3.6.1