func (c Color) Mix(color Color, weight float64) Color {
	oWeight := 1 - weight
	r := math.Round(oWeight*c.Red + weight*color.Red)
	g := math.Round(oWeight*c.Green + weight*color.Green)
	b := math.Round(oWeight*c.Blue + weight*color.Blue)
	a := math.Round(oWeight*c.Alpha + weight*color.Alpha)
	return newColor(r, g, b, a)
}
Mix mixs both color with the specified weight of the second color. (`0.5` as `50%`)
package noire
import (
	"encoding/hex"
	"fmt"
	"math"
	"strings"
)
type Color struct {
	Red   float64
	Green float64
	Blue  float64
	Alpha float64
}
func newColor(r float64, g float64, b float64, a float64) Color {
	if r > 255 {
		r = 255
	} else if r < 0 {
		r = 0
	}
	if g > 255 {
		g = 255
	} else if g < 0 {
		g = 0
	}
	if b > 255 {
		b = 255
	} else if b < 0 {
		b = 0
	}
	if a > 1 {
		a = 1
	} else if a < 0 {
		a = 0
	}
	return Color{
		Red:   r,
		Green: g,
		Blue:  b,
		Alpha: a,
	}
}
func CMYKToRGB(c float64, m float64, y float64, k float64) (r float64, g float64, b float64) {
	c = c / 100
	m = m / 100
	y = y / 100
	k = k / 100
	r = 1 - math.Min(1, c*(1-k)+k)
	g = 1 - math.Min(1, m*(1-k)+k)
	b = 1 - math.Min(1, y*(1-k)+k)
	r = math.Round(r * 255)
	g = math.Round(g * 255)
	b = math.Round(b * 255)
	return
}
func RGBToCMYK(r float64, g float64, b float64) (c float64, m float64, y float64, k float64) {
	r = r / 255
	g = g / 255
	b = b / 255
	k = math.Min(1-r, 1-g)
	k = math.Min(k, 1-b)
	if (1 - k) == 0 {
		c = 0
		m = 0
		y = 0
	} else {
		c = (1 - r - k) / (1 - k)
		m = (1 - g - k) / (1 - k)
		y = (1 - b - k) / (1 - k)
	}
	c = math.Round(c * 100)
	m = math.Round(m * 100)
	y = math.Round(y * 100)
	k = math.Round(k * 100)
	return
}
func HueToRGB(p float64, q float64, t float64) float64 {
	if t < 0 {
		t++
	}
	if t > 1 {
		t--
	}
	if t < float64(1)/float64(6) {
		return p + (q-p)*6*t
	}
	if t < float64(1)/float64(2) {
		return q
	}
	if t < float64(2)/float64(3) {
		return p + (q-p)*(float64(2)/float64(3)-t)*6
	}
	return p
}
func RGBToHSL(r float64, g float64, b float64) (h float64, s float64, l float64) {
	r = r / 255
	g = g / 255
	b = b / 255
	max := math.Max(r, g)
	max = math.Max(max, b)
	min := math.Min(r, g)
	min = math.Min(min, b)
	l = (max + min) / 2
	if max == min {
		h = 0
		s = 0
	} else {
		d := max - min
		if l > 0.5 {
			s = d / (2 - max - min)
		} else {
			s = d / (max + min)
		}
		switch max {
		case r:
			if g < b {
				h = (g-b)/d + 6
			} else {
				h = (g-b)/d + 0
			}
			break
		case g:
			h = (b-r)/d + 2
			break
		case b:
			h = (r-g)/d + 4
			break
		}
	}
	h = math.Round(h * 60)
	s = math.Round(s*1000) / 10
	l = math.Round(l*1000) / 10
	return
}
func HSLToRGB(h float64, s float64, l float64) (r float64, g float64, b float64) {
	h = h / 360
	s = s / 100
	l = l / 100
	if s == 0 {
		r = l
		g = l
		b = l
	} else {
		var q float64
		if l < 0.5 {
			q = l * (1 + s)
		} else {
			q = l + s - l*s
		}
		p := 2*l - q
		r = HueToRGB(p, q, h+float64(float64(1)/float64(3)))
		g = HueToRGB(p, q, h)
		b = HueToRGB(p, q, h-float64(float64(1)/float64(3)))
	}
	r = math.Round(r * 255)
	g = math.Round(g * 255)
	b = math.Round(b * 255)
	return
}
func HSVToRGB(h float64, s float64, v float64) (r float64, g float64, b float64) {
	s = s / 100
	v = v / 100
	c := v * s
	hh := h / 60
	x := c * (1 - math.Abs(math.Mod(hh, 2)-1))
	if hh >= 0 && hh < 1 {
		r = c
		g = x
	} else if hh >= 1 && hh < 2 {
		r = x
		g = c
	} else if hh >= 2 && hh < 3 {
		g = c
		b = x
	} else if hh >= 3 && hh < 4 {
		g = x
		b = c
	} else if hh >= 4 && hh < 5 {
		r = x
		b = c
	} else {
		r = c
		b = x
	}
	m := v - c
	r += m
	g += m
	b += m
	r = math.Round(r * 255)
	g = math.Round(g * 255)
	b = math.Round(b * 255)
	return
}
func RGBToHSV(r float64, g float64, b float64) (h float64, s float64, v float64) {
	r = r / 255
	g = g / 255
	b = b / 255
	minValue := math.Min(math.Min(r, g), b)
	maxValue := math.Max(math.Max(r, g), b)
	delta := maxValue - minValue
	v = maxValue
	if delta == 0 {
		h = 0
		s = 0
	} else {
		s = delta / maxValue
		deltaR := (((maxValue - r) / 6) + (delta / 2)) / delta
		deltaG := (((maxValue - g) / 6) + (delta / 2)) / delta
		deltaB := (((maxValue - b) / 6) + (delta / 2)) / delta
		switch maxValue {
		case r:
			h = deltaB - deltaG
			break
		case g:
			h = (float64(1) / float64(3)) + deltaR - deltaB
			break
		case b:
			h = (float64(2) / float64(3)) + deltaG - deltaR
			break
		}
		if h < 0 {
			h++
		}
		if h > 1 {
			h--
		}
	}
	h = math.Round(h * 360)
	s = math.Round(s*1000) / 10
	v = math.Round(v*1000) / 10
	return
}
func RGBToHex(r float64, g float64, b float64) string {
	h := []byte{uint8(math.Round(r)), uint8(math.Round(g)), uint8(math.Round(b))}
	return strings.ToUpper(hex.EncodeToString(h))
}
func HexToRGB(h string) (r float64, g float64, b float64) {
	if string(h[0]) == "#" {
		h = h[1:]
	}
	if len(h) == 3 {
		h = string(h[0]) + string(h[0]) + string(h[1]) + string(h[1]) + string(h[2]) + string(h[2])
	}
	byteArray, _ := hex.DecodeString(h)
	r = float64(byteArray[0])
	g = float64(byteArray[1])
	b = float64(byteArray[2])
	return
}
func HTMLToRGB(h string) (r float64, g float64, b float64) {
	if string(h[0]) == "#" {
		h = h[1:]
		r, g, b = HexToRGB(h)
	} else {
		v, ok := colorNames[strings.ToUpper(h)]
		if !ok {
			r = 0
			g = 0
			b = 0
			return
		}
		r, g, b = HexToRGB(v)
	}
	return
}
func RGBToHTML(r float64, g float64, b float64) (h string) {
	h = RGBToHex(r, g, b)
	v, ok := hexNames[h]
	if !ok {
		h = "#" + h
		return
	}
	h = v
	return
}
func NewHTML(color string) Color {
	r, g, b := HTMLToRGB(color)
	return newColor(r, g, b, 1)
}
func NewHTMLA(color string, a float64) Color {
	r, g, b := HTMLToRGB(color)
	return newColor(r, g, b, a)
}
func NewHex(color string) Color {
	r, g, b := HexToRGB(color)
	return newColor(r, g, b, 1)
}
func NewHexA(color string, a float64) Color {
	r, g, b := HexToRGB(color)
	return newColor(r, g, b, a)
}
func NewHSL(h float64, s float64, l float64) Color {
	r, g, b := HSLToRGB(h, s, l)
	return newColor(r, g, b, 1)
}
func NewHSLA(h float64, s float64, l float64, a float64) Color {
	r, g, b := HSLToRGB(h, s, l)
	return newColor(r, g, b, a)
}
func NewHSV(h float64, s float64, v float64) Color {
	r, g, b := HSVToRGB(h, s, v)
	return newColor(r, g, b, 1)
}
func NewHSVA(h float64, s float64, v float64, a float64) Color {
	r, g, b := HSVToRGB(h, s, v)
	return newColor(r, g, b, a)
}
func NewRGB(r float64, g float64, b float64) Color {
	return newColor(r, g, b, 1)
}
func NewRGBA(r float64, g float64, b float64, a float64) Color {
	return newColor(r, g, b, a)
}
func NewCMYK(c float64, m float64, y float64, k float64) Color {
	r, g, b := CMYKToRGB(c, m, y, k)
	return newColor(r, g, b, 1)
}
func NewCMYKA(c float64, m float64, y float64, k float64, a float64) Color {
	r, g, b := CMYKToRGB(c, m, y, k)
	return newColor(r, g, b, a)
}