ansirgb

package module
v0.0.0-...-c938d9f Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: ISC Imports: 2 Imported by: 1

README

ansirgb

A package for converting color.Colors to ANSI color codes, 256 colors supported.

Example

package main

import (
	"fmt"
	"image/color"
	"github.com/stroborobo/ansirgb"
)

func main() {
	rgbColor := &color.RGBA{20, 80, 200, 255}
	ansiColor := ansirgb.Convert(rgbColor)
	fmt.Printf("%s%s\n", ansiColor.Fg(), "Foobar")
}

=> colored output (dark blue)

Installation

> go get github.com/stroborobo/ansirgb

Have fun :)

Documentation

Documentation is available at GoDoc.org.

Documentation

Overview

Package ansirgb converts color.Color's to ANSI colors

Index

Constants

This section is empty.

Variables

View Source
var (
	// Palette contains all 256 ANSI colors
	Palette = make(color.Palette, 0, 255)
)

Functions

This section is empty.

Types

type Color

type Color struct {
	color.Color
	Code int
}

Color represents an ANSI color

func Convert

func Convert(c color.Color) *Color

Convert returns the ANSI color closest to c.

func (*Color) Bg

func (c *Color) Bg() string

Bg returns the escape code for background color

func (*Color) Equals

func (c *Color) Equals(rhs *Color) bool

func (*Color) Fg

func (c *Color) Fg() string

Fg returns the escape code for foreground color

func (*Color) IsTransparent

func (c *Color) IsTransparent() bool

IsTransparent returns if the color is a transparent one

func (*Color) String

func (c *Color) String() string

String returns a small description of the color containing ANSI code and a hex representation of the RGB value, e.g. " 26: 0000 4B4B D2D2"

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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