color

package module
v0.0.0-...-7e25f6e Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: MIT Imports: 2 Imported by: 1

README

#color

import (
	"image/color"
	"fmt"
	hbscolor "github.com/mengxiaozhu/color"
)

func main() {
	count,incorrect:=0,0
	for r:=0;r<256;r++{
		for g:=0;g<256;g++{
			for b:=0;b<256;b++{
				c:=color.RGBA{R:uint8(r), G: uint8(g), B:uint8(b)}
				hbs :=hbscolor.RGBToHLS(c)
				count++
				rgb:=hbs.HSB2RGB()
				if(c.R!=rgb.R||c.G!=rgb.G||c.B!=rgb.B){
					incorrect++
				}
			}
		}
	}
	fmt.Println("count:",count,"incorrect",incorrect,float64(incorrect)/float64(count),"%")
}

output

count: 16777216 incorrect 8099558 0.48277127742767334 %

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HSB

type HSB struct {
	H    float64 //色相
	S, B float64 // ,饱和度(纯度),l/b亮度
}

func RGBToHLS

func RGBToHLS(rgb color.RGBA) (hsb HSB)

func (HSB) Gethsb

func (hsb HSB) Gethsb() (int, int, int)

func (HSB) HSB2RGB

func (hsl HSB) HSB2RGB() color.RGBA

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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