badge

package module
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

README

PkgGoDev GitHub Actions CI Status GoReportCard Coverage Status Codebeat badge GitHub Actions CodeQL Status

InstallationUsage exampleExamplesBuild StatusContributingThanksLicense


badge is a Go package for generating SVG badges.

Installation

Make sure you have a working Go 1.18+ workspace (instructions), then:

go get github.com/essentialkaos/go-badge

Usage example

package main

// ////////////////////////////////////////////////////////////////////////// //

import (
  "fmt"
  "github.com/essentialkaos/go-badge"
)

// ////////////////////////////////////////////////////////////////////////// //

func main() {
  g, err := badge.NewGenerator("Verdana.ttf", 11)

  if err != nil {
    panic(err)
  }

  fmt.Println(string(g.GeneratePlastic("status", "ok", "#97ca00")))
}

Examples

Flat Flat Square Plastic Flat (Simple) Flat Square (Simple) Plastic (Simple)
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple
flat square plastic flat-simple square-simple plastic-simple

All badges are generated with the latest version of the package.

Build Status

Branch Status
master CI
develop CI

Contributing

Before contributing to this project please read our Contributing Guidelines.

Thanks

We would like to thank:

License

Apache License, Version 2.0

Documentation

Overview

Package badge provides methods for generating SVG badges

Index

Constants

View Source
const (
	COLOR_BLUE        = "#007ec6"
	COLOR_BRIGHTGREEN = "#4c1"
	COLOR_GREEN       = "#97ca00"
	COLOR_GREY        = "#555"
	COLOR_LIGHTGREY   = "#9f9f9f"
	COLOR_ORANGE      = "#fe7d37"
	COLOR_RED         = "#e05d44"
	COLOR_YELLOW      = "#dfb317"
	COLOR_YELLOWGREEN = "#a4a61d"

	COLOR_SUCCESS       = "#4c1"
	COLOR_IMPORTANT     = "#fe7d37"
	COLOR_CRITICAL      = "#e05d44"
	COLOR_INFORMATIONAL = "#007ec6"
	COLOR_INACTIVE      = "#9f9f9f"
)
View Source
const (
	DEFAULT_OFFSET  = 9 // default font offset
	DEFAULT_SPACING = 0 // default letter spacing
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Offset  int     // Text offset
	Spacing float64 // Letter spacing
	// contains filtered or unexported fields
}

Generator is badge generator

func NewGenerator

func NewGenerator(fontFile string, fontSize int) (*Generator, error)

NewGenerator creates new badge generator with given font

func (*Generator) GenerateFlat

func (g *Generator) GenerateFlat(label, message, color string) []byte

GenerateFlat generates SVG badge in flat style

func (*Generator) GenerateFlatSimple added in v1.2.0

func (g *Generator) GenerateFlatSimple(message, color string) []byte

GenerateFlatSimple generates SVG simple badge in flat style

func (*Generator) GenerateFlatSquare

func (g *Generator) GenerateFlatSquare(label, message, color string) []byte

GenerateFlatSquare generates SVG badge in flat-square style

func (*Generator) GenerateFlatSquareSimple added in v1.2.0

func (g *Generator) GenerateFlatSquareSimple(message, color string) []byte

GenerateFlatSquareSimple generates SVG simple badge in flat-square style

func (*Generator) GeneratePlastic

func (g *Generator) GeneratePlastic(label, message, color string) []byte

GeneratePlastic generates SVG badge in plastic style

func (*Generator) GeneratePlasticSimple added in v1.2.0

func (g *Generator) GeneratePlasticSimple(message, color string) []byte

GeneratePlasticSimple generates SVG simple badge in plastic style

Jump to

Keyboard shortcuts

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