color

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color struct {
	// contains filtered or unexported fields
}

Color encodes a color.NRGBA color which is widely used by Gio. It provides method to convert the non-alpha-premultiplied color to a color OP used by Gio ops.

func Hex2Color

func Hex2Color(hexStr string) (Color, error)

Hex2Color converts a non-alpha-premultiplied hexadecimal color string to Color. The hexadecimal color can be in RGB or RGBA format. A "#" prefix is also allowed.

Example formats: "#RRGGBB", "RRGGBBAA", "RRGGBB".

func MakeColor

func MakeColor(val color.NRGBA) Color

func (Color) IsSet

func (c Color) IsSet() bool

func (Color) MulAlpha

func (c Color) MulAlpha(alpha uint8) Color

MulAlpha applies the alpha to the color and return the modified one.

func (Color) NRGBA

func (c Color) NRGBA() color.NRGBA

func (*Color) Op

func (c *Color) Op(ops *op.Ops) op.CallOp

func (Color) String

func (c Color) String() string

type ColorPalette

type ColorPalette struct {
	// Foreground provides a default text color for the editor.
	Foreground Color
	// Background provides a default text color for the editor.
	Background Color
	// Color used to highlight the selections.
	SelectColor Color
	// Color used to highlight the current paragraph.
	LineColor Color
	// Color used to paint the line number
	LineNumberColor Color
	// contains filtered or unexported fields
}

ColorPalette manages used color of TextPainter. Color is added and referenced by its ID(index) in the palette.

func (*ColorPalette) AddColor

func (p *ColorPalette) AddColor(cl Color) int

AddColor adds a color to the palette and return its id(index).

func (*ColorPalette) Clear

func (p *ColorPalette) Clear()

Clear clear all added colors.

func (*ColorPalette) GetColor

func (p *ColorPalette) GetColor(id int) Color

GetColor retrieves a Color by its ID. ID can be acquired when adding the color to the palette.

Jump to

Keyboard shortcuts

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