color

package
v0.0.0-...-8dd99ce Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package color implements an RGB color value and provides common utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	White = Color{1, 1, 1}
	Red   = Color{1, 0, 0}
	Green = Color{0, 1, 0}
	Blue  = Color{0, 0, 1}
	Black = Color{0, 0, 0}
)

Functions

func Equal

func Equal(c1, c2 Color) bool

Equal returns true if the given Colors are equal.

Types

type Color

type Color struct {
	R, G, B float64
}

A Color represents an RGB color with component values between [0,1]. The zero value for Color is black.

func Add

func Add(c1, c2 Color) Color

Add returns the component-wise sum of two Colors.

func Clamp

func Clamp(c Color) Color

Clamp returns a Color whose component values are clamped between [0,1].

If a component value is less than 0, the component is set to 0. If it is greater than 1, the component is set to 1. Otherwise, the component is left unchanged.

func Mult

func Mult(c Color, scalar float64) Color

Mult scales each component of a Color c by the given scalar.

func New

func New(r, g, b float64) Color

New returns a new Color literal.

func PiecewiseMult

func PiecewiseMult(c1 Color, c2 Color) Color

PiecewiseMult returns the component-wise product of two Colors.

func Sub

func Sub(c1, c2 Color) Color

Sub returns the component-wise difference of two Colors.

func (Color) Add

func (c1 Color) Add(c2 Color) Color

Add returns the component-wise sum of two Colors.

func (Color) Sub

func (c1 Color) Sub(c2 Color) Color

Sub returns the component-wise difference of two Colors.

Jump to

Keyboard shortcuts

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