colorf

package
v0.0.0-...-405cb25 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package colorf provides a floating-point color implementation.

Index

Constants

This section is empty.

Variables

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

Functions

func EV

func EV(exp float64) float64

Exposure value, 2^exp.

func LinearToSRGB

func LinearToSRGB(c float64) float64

linear to sRGB conversion https://en.wikipedia.org/wiki/SRGB

func SRGBSlope

func SRGBSlope(c float64) float64

Slope of linear to SRGB curve (without clipping).

func SRGBToLinear

func SRGBToLinear(s float64) float64

sRGB to linear conversion https://en.wikipedia.org/wiki/SRGB TODO: Look-up table for bytes

Types

type Color

type Color struct {
	R, G, B float64
}

Color represents either a reflectivity or intensity.

In case of reflectivity, values should be [0..1], 1 meaning 100% reflectivity for that color.

The color space is linear.

func Gray

func Gray(v float64) Color

func (Color) Add

func (c Color) Add(b Color) Color

Adds two colors (i.e. blends them).

func (Color) At

func (c Color) At(_ geom.Vec) Color

At implements tracer.Texture3D.

func (Color) AtUV

func (c Color) AtUV(u, v float64) Color

AtUV implements tracer.Texture2D.

func (Color) EV

func (c Color) EV(ev float64) Color

Multiplies the color by 2^ev. E.g.:

RED.EV(-1) // 50% reflective red, i.e. dark red.

func (Color) Gray

func (c Color) Gray() float64

func (Color) IsNaN

func (a Color) IsNaN() bool

func (Color) MAdd

func (c Color) MAdd(a float64, b Color) Color

Adds s*b to color c.

func (*Color) Max

func (c *Color) Max() float64

func (Color) Mul

func (c Color) Mul(a float64) Color

Multiplies the color, making it darker (s<1) or brighter (s>1). E.g.:

RED.Mul(0.5) // 50% reflective red, i.e. dark red.

func (Color) Mul3

func (c Color) Mul3(b Color) Color

Point-wise multiplication of two colors. E.g.: light reflecting off a colored surface.

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

Implements color.Color. Converts from float64 linear space to 16-bit srgb.

Jump to

Keyboard shortcuts

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