flying-anvil/badge-generator

It generates badges as .svg

1.0.3 2019-10-10 12:32 UTC

This package is not auto-updated.

Last update: 2024-10-04 13:36:37 UTC


README

Tool for generating badges, like

coverage php-version

How To

Executable Script

Run the generate.php script to generate a badge.

It accespts some parameters to customize the result:

shortlongdescriptiondefault
ooutputfile to write tostdout
lleftspecifies the left text
rrightspecifies the right text
gno-gradientno value, removes the gradient in the badgeomitted
pno-percentage-coloringno value, disables auto-coloring based on the right textomitted
radiusradius of the edges5.0
left-text-colorcolor of the left texteeeeee
right-text-colorcolor of the right texteeeeee
left-background-colorbackground color of the left segment555555
right-background-colorbackground color of the right segment4B3D6C
low-percent-colorright background color for 0% when using auto coloringB31329
mid-percent-colorright background color for 50% when using auto coloringCDAB58
hight-percent-colorright background color for 100% when using auto coloring2AC258

Using Generator

Create a Generator and feed it with some options:

<?php

require_once __DIR__ . '/../vendor/autoload.php';

$badgeOptions = \FlyingAnvil\BadgeGenerator\Application\DataObject\BadgeOptions::create('left', 'right');
$badgeOptions->setLeftText('direction');
$badgeOptions->setRadius(3);
$badgeOptions->setLeftBackgroundColor(\FlyingAnvil\BadgeGenerator\Application\DataObject\Color::createFromHex('00cc00'));

$badgeGenerator = new \FlyingAnvil\BadgeGenerator\Application\Service\Generator();
$badge          = $badgeGenerator->generate($badgeOptions);

echo $badge;