Compare commits

...

2 commits

Author SHA1 Message Date
16881d5e5a
Renamed files
All checks were successful
/ test (push) Successful in 14s
2025-06-06 17:07:05 +02:00
9c8f71be07
Updated formatting 2025-06-06 17:05:55 +02:00
26 changed files with 25 additions and 25 deletions

2
.gitignore vendored
View file

@ -4,4 +4,4 @@
!*.go !*.go
!*.md !*.md
!*.mod !*.mod
!*.sum !*.sum

View file

@ -39,4 +39,4 @@ func (c Color) Println(args ...any) {
} }
fmt.Printf("\x1b[38;2;%d;%d;%dm%s\n\x1b[0m", c.R, c.G, c.B, fmt.Sprint(args...)) fmt.Printf("\x1b[38;2;%d;%d;%dm%s\n\x1b[0m", c.R, c.G, c.B, fmt.Sprint(args...))
} }

View file

@ -52,4 +52,4 @@ func TestPrintln(t *testing.T) {
color.RGB(1, 0, 0).Println("red") color.RGB(1, 0, 0).Println("red")
color.RGB(0, 1, 0).Println("green") color.RGB(0, 1, 0).Println("green")
color.RGB(0, 0, 1).Println("blue") color.RGB(0, 0, 1).Println("blue")
} }

2
HSL.go
View file

@ -26,4 +26,4 @@ func HSL(hue Value, saturation Value, lightness Value) Color {
m := lightness - c/2 m := lightness - c/2
return RGB(r+m, g+m, b+m) return RGB(r+m, g+m, b+m)
} }

View file

@ -23,4 +23,4 @@ func TestHSLSpectrum(t *testing.T) {
fmt.Println() fmt.Println()
} }
} }

2
HSV.go
View file

@ -26,4 +26,4 @@ func HSV(hue Value, saturation Value, value Value) Color {
m := value - c m := value - c
return RGB(r+m, g+m, b+m) return RGB(r+m, g+m, b+m)
} }

View file

@ -23,4 +23,4 @@ func TestHSVSpectrum(t *testing.T) {
fmt.Println() fmt.Println()
} }
} }

2
LCH.go
View file

@ -57,4 +57,4 @@ func oklabToLinearRGB(lightness Value, a Value, b Value) (Value, Value, Value) {
blue := -0.0041960863*l - 0.7034186147*m + 1.7076147010*s blue := -0.0041960863*l - 0.7034186147*m + 1.7076147010*s
return red, green, blue return red, green, blue
} }

View file

@ -48,4 +48,4 @@ func TestLCHSpectrum(t *testing.T) {
fmt.Println() fmt.Println()
} }
} }

2
RGB.go
View file

@ -33,4 +33,4 @@ func sRGB(x Value) Value {
} }
return 1.0 return 1.0
} }

View file

@ -26,4 +26,4 @@ func TestRGB(t *testing.T) {
for name, c := range rgbColors { for name, c := range rgbColors {
c.Println("█ " + name) c.Println("█ " + name)
} }
} }

View file

@ -10,4 +10,4 @@ import (
var Terminal = tty.IsTerminal(os.Stdout.Fd()) var Terminal = tty.IsTerminal(os.Stdout.Fd())
// TrueColor indicates if the terminal has 24-bit color support. // TrueColor indicates if the terminal has 24-bit color support.
var TrueColor = os.Getenv("COLORTERM") == "truecolor" var TrueColor = os.Getenv("COLORTERM") == "truecolor"

View file

@ -1,4 +1,4 @@
package color package color
// Value is a type definition for the data type of a single color component. // Value is a type definition for the data type of a single color component.
type Value = float64 type Value = float64

View file

@ -37,4 +37,4 @@ func (code Code) Println(args ...any) {
} }
fmt.Printf("\x1b[%dm%s\n\x1b[0m", code, fmt.Sprint(args...)) fmt.Printf("\x1b[%dm%s\n\x1b[0m", code, fmt.Sprint(args...))
} }

View file

@ -52,4 +52,4 @@ func testPrintln() {
ansi.Yellow.Println("Yellow") ansi.Yellow.Println("Yellow")
ansi.Magenta.Println("Magenta") ansi.Magenta.Println("Magenta")
ansi.Cyan.Println("Cyan") ansi.Cyan.Println("Cyan")
} }

View file

@ -9,4 +9,4 @@ const (
Magenta Magenta
Cyan Cyan
White White
) )

View file

@ -11,4 +11,4 @@ const (
Reverse Reverse
Hidden Hidden
Strikethrough Strikethrough
) )

View file

@ -34,4 +34,4 @@ func BenchmarkPrintRaw(b *testing.B) {
for b.Loop() { for b.Loop() {
c.Print("") c.Print("")
} }
} }

2
go.mod
View file

@ -2,4 +2,4 @@ module git.urbach.dev/go/color
go 1.24 go 1.24
require golang.org/x/sys v0.31.0 require golang.org/x/sys v0.31.0

2
go.sum
View file

@ -1,2 +1,2 @@
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=

View file

@ -8,4 +8,4 @@ import "golang.org/x/sys/unix"
func IsTerminal(fd uintptr) bool { func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA) _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
return err == nil return err == nil
} }

View file

@ -8,4 +8,4 @@ import "golang.org/x/sys/unix"
func IsTerminal(fd uintptr) bool { func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS) _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
return err == nil return err == nil
} }

View file

@ -5,4 +5,4 @@ package tty
// IsTerminal is always false on unsupported platforms. // IsTerminal is always false on unsupported platforms.
func IsTerminal(fd uintptr) bool { func IsTerminal(fd uintptr) bool {
return false return false
} }

View file

@ -9,4 +9,4 @@ import (
func TestIsTerminal(t *testing.T) { func TestIsTerminal(t *testing.T) {
tty.IsTerminal(os.Stdout.Fd()) tty.IsTerminal(os.Stdout.Fd())
} }

View file

@ -9,4 +9,4 @@ func IsTerminal(fd uintptr) bool {
var mode uint32 var mode uint32
err := windows.GetConsoleMode(windows.Handle(fd), &mode) err := windows.GetConsoleMode(windows.Handle(fd), &mode)
return err == nil return err == nil
} }