colette

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: ISC Imports: 0 Imported by: 1

README

colette

Go Reference Go Report Card codecov

Convert between truecolor, xterm(1) 256 color and 16 color. Single-header library. Arranged from tmux.

C

Install

Using prebuilt packages:

Download artifacts from Releases, including:

  • The header source

  • Deb package

  • Rpm package

Or using make install:

mkdir build && cd build && cmake .. && make && make install

Or using submodule:

git submodule add --name colette https://github.com/ifrstr/colette.git colette
add_subdirectory(colette)
Usage

Checkout colette.h.

Go

Install

go get gopkg.ilharper.com/x/colette
Usage

Go Reference

LICENSE

ISC, the same as tmux

Documentation

Overview

Convert between truecolor, xterm(1) 256 color and 16 color. Single-header library. Arranged from tmux.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Color256To16

func Color256To16(c byte) byte

Color256To16 converts 256 color to 16 color.

func Color256ToRgb

func Color256ToRgb(c byte) int

Color256ToRgb converts 256 color to RGB color.

func JoinRgb

func JoinRgb(r, g, b byte) int

JoinRgb joins RGB into a color.

func RgbTo256

func RgbTo256(r, g, b byte) int

RgbTo256 converts an RGB triplet to the xterm(1) 256 color palette.

xterm provides a 6x6x6 color cube (16 - 231) and 24 greys (232 - 255). We map our RGB color to the closest in the cube, also work out the closest grey, and use the nearest of the two.

Note that the xterm has much lower resolution for darker colors (they are not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more evenly spread (8, 18, 28 ... 238).

func SplitRgb

func SplitRgb(c int) (r, g, b byte)

SplitRgb converts 256 color to RGB color.

Types

This section is empty.

Jump to

Keyboard shortcuts

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