amberlampsio/racetrack-generator

There is no license information available for the latest version (dev-master) of this package.

Generate mock racetrack images on the fly

dev-master 2018-12-07 16:26 UTC

README

Simple 2D Race Track Generator

Installation

composer require amberlampsio/racetrack-generator

Requirement

ImageMagick

Usage Examples

$track = (new Track())->drawTrack();
        
header("Content-Type: image/png");
echo $track->getImageBlob();

Additional Options

$track = (new Track())
          ->setBackgroundColor('black')
          ->setStrokeColor('white')
          ->setStrokeWidth(2)
          ->setStrokeOpacity(0.8)
          ->drawTrack(); //returns an Imagick Object
          

$track->setImageFormat("png");
$track->trimImage(0);
	
//square up an image
$track->rotateImage('black', 45);
$track->scaleImage(300, 300, true);
	
header("Content-Type: image/png");
echo $track->getImageBlob();

Credit

This is a port of a JavaScript Racetrack generator found on, http://static.opengameart.org/procgen/track.html https://opengameart.org/forumtopic/procedural-racetrack-generation-in-javascript