This repository has been archived on 2023-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
humanshader/hsv.go

34 lines
682 B
Go
Raw Normal View History

2023-07-19 22:00:00 +02:00
package main
import (
"bufio"
"fmt"
hsv "git.snrd.eu/sunred/humanshader/validator"
"os"
"strconv"
)
func main() {
args := os.Args[1:]
var pxX int
var pxY int
if len(args) == 2 {
pxX, _ = strconv.Atoi(args[0])
pxY, _ = strconv.Atoi(args[1])
} else {
fmt.Print("Pixel x coordinate: ")
input := bufio.NewScanner(os.Stdin)
input.Scan()
pxX, _ = strconv.Atoi(input.Text())
fmt.Print("Pixel y coordinate: ")
input = bufio.NewScanner(os.Stdin)
input.Scan()
pxY, _ = strconv.Atoi(input.Text())
}
val := hsv.NewValidator(true)
val.Calculate(pxX, pxY)
r, g, b := val.GetColor()
fmt.Printf("R: %d\nG: %d\nB: %d\nHEX: #%02X%02X%02X\n", r, g, b, r, g, b)
}