dsibilio / badge-maker

A lightweight Java SVG badge/shield generation library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configurable Size

MeyerDaniel opened this issue · comments

Hi there,
many thanks to this library, which I will adopt within a serverless service. If you don't mind I would like to make one suggestion. It would be nice to have the possibility to specify the size of these badges, maybe with named constants.

Any thoughts?
BR, Daniel

Hi Daniel,

since the badge is just an SVG element it is quite easy for the final consumer of the badge to determine the actual size of the rendered badge, but I can see how - depending on the intended usage - it might be more convenient to be able to generate an upscaled badge straight away rather than having the final user upscale it through any other means (eg. CSS, manually editing the XML).

I think it should be easy enough to upscale the SVG within the renderer code of this library by multiplying the width/height SVG header values by x and providing transform="scale(x)" attributes for all of the g elements of the SVG. This would allow users of this library to provide the x as any number between 1 and Integer.MAX_VALUE determining the scale of the SVG, where 1 is the original size that is being produced now, 2 would be 2x the size and so on.

Would this kind of solution suffice your needs?

@MeyerDaniel you can verify the changes coming from this PR: #3.