/gradient

🌈 An endpoint for all your gradient needs

Primary LanguageJavaScriptMIT LicenseMIT


example gradient

Gradient

check out the demo deploy to heroku



Examples

boop gradient fizz gradient buzz gradient ok radial gradient yep wide gradient
/boop /fizz /buzz /ok/radial /yep/linear/160,80

Usage

Generate a gradient by passing a string (eg. username or email) as a URL path to your endpoint, for example microgradient.herokuapp.com/shwilliam. A request for a gradient will, by default, return a 200px by 200px SVG.

Path

The path of the request is used to pass a string used to seed the gradient. Optionally, you can also specify the type of gradient to be generated, as well as its size. For example, /janedoe/radial/42,42 will return a radial, 42px by 42px SVG gradient.

Parameters

Pass optional URL query parameters to format the requested gradient.

Key Required Default Type Example
type 'svg' 'svg' | 'png' | 'jpeg' | 'ico' ?type=png
size 200 Number (single or comma-separated tuple) ?size=20
?size=100,20
variant 'linear' 'linear' | 'radial' ?variant=radial
text none String ?text=JD

ICO

Generating an ICO version of a gradient works a bit differently. Passing type=ico returns a page with a download link for the file. Note that the icon created will always be 14px by 14px; passing a size parameter will not have any effect.

Development

npm i
npm run dev

Production

npm i
npm run build
npm start

Dockerized

docker build --tag gg:1.0 .
docker run -p 1234:1234 -d --name gg gg:1.0

References

This project leans heavily on the sharp library for image processing and color for color manipulation. Other open-source projects that offer similar solutions to this one include get-gravatar and avatar.

Contributing

This project is open to and encourages contributions! Feel free to discuss any bug fixes/features in the issues. If you wish to work on this project:

  1. Fork this project
  2. Create a branch (git checkout -b new-branch)
  3. Commit your changes (git commit -am 'add new feature')
  4. Push to the branch (git push origin new-branch)
  5. Submit a pull request!