badge

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 8 Imported by: 0

README

go-badge

license Go Report Card

go-badge is a library to render shield badges to SVG.

This software has been provided as https://github.com/narqo/go-badge at first and it is modified by gjbae1212.

narqo/go-badge that originally was made has licensed under the MIT.

This forked project is following the MIT.

Installation

Using go get

go get github.com/gjbae1212/go-badge

Usage

package main

import (
	"fmt"
	"os"

	"github.com/gjbae1212/go-badge"
)

func main() {
	err := badge.Render("godoc", "reference", "#5272B4", os.Stdout)
	if err != nil {
		panic(err)
	}

	badge, err := badge.RenderBytes("godoc", "reference", "#5272B4")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s", badge)
}

License

MIT


All the kudos should go to the great Shields.io specification project.

Documentation

Index

Constants

View Source
const (
	ColorBrightgreen = Color("brightgreen")
	ColorGreen       = Color("green")
	ColorYellow      = Color("yellow")
	ColorYellowgreen = Color("yellowgreen")
	ColorOrange      = Color("orange")
	ColorRed         = Color("red")
	ColorBlue        = Color("blue")
	ColorGrey        = Color("grey")
	ColorGray        = Color("gray")
	ColorLightgrey   = Color("lightgrey")
	ColorLightgray   = Color("lightgray")
)

Standard colors.

Variables

View Source
var ColorScheme = map[string]string{
	"brightgreen": "#4c1",
	"green":       "#97ca00",
	"yellow":      "#dfb317",
	"yellowgreen": "#a4a61d",
	"orange":      "#fe7d37",
	"red":         "#e05d44",
	"blue":        "#007ec6",
	"grey":        "#555",
	"gray":        "#555",
	"lightgrey":   "#9f9f9f",
	"lightgray":   "#9f9f9f",
}

ColorScheme contains named colors that could be used to render the badge.

Functions

func Render

func Render(subject, status string, color Color, w io.Writer) error

Render renders a badge of the given color, with given subject and status to w.

func RenderBytes

func RenderBytes(subject, status string, color Color) ([]byte, error)

RenderBytes renders a badge of the given color, with given subject and status to bytes.

Types

type Color

type Color string

Color represents color of the badge.

func (Color) String

func (c Color) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL