From e0fb010ae164c608eae0024d5cbef80fa5794db0 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 25 Dec 2017 17:17:50 +0800 Subject: [PATCH] add more color examples --- examples/main.go | 12 ++++++++++++ examples/screen/main.go | 12 ++++++++++++ screen/goScreen.h | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/examples/main.go b/examples/main.go index 2a55f21..2625fa4 100644 --- a/examples/main.go +++ b/examples/main.go @@ -125,8 +125,20 @@ func screen() { // gets the pixel color at 100, 200. color := robotgo.GetPixelColor(100, 200) fmt.Println("color----", color, "-----------------") + clo := robotgo.GetPxColor(100, 200) fmt.Println("color...", clo) + clostr := robotgo.PadHex(clo) + fmt.Println("color...", clostr) + + rgb := robotgo.RgbToHex(255, 100, 200) + rgbstr := robotgo.PadHex(robotgo.U32ToHex(rgb)) + fmt.Println("rgb...", rgbstr) + + hex := robotgo.HexToRgb(uint32(rgb)) + fmt.Println("hex...", hex) + hexh := robotgo.PadHex(robotgo.U8ToHex(hex)) + fmt.Println("HexToRgb...", hexh) // gets the pixel color at 10, 20. color2 := robotgo.GetPixelColor(10, 20) diff --git a/examples/screen/main.go b/examples/screen/main.go index 83806ee..20af2ab 100644 --- a/examples/screen/main.go +++ b/examples/screen/main.go @@ -38,8 +38,20 @@ func main() { // gets the pixel color at 100, 200. color := robotgo.GetPixelColor(100, 200) fmt.Println("color----", color, "-----------------") + clo := robotgo.GetPxColor(100, 200) fmt.Println("color...", clo) + clostr := robotgo.PadHex(clo) + fmt.Println("color...", clostr) + + rgb := robotgo.RgbToHex(255, 100, 200) + rgbstr := robotgo.PadHex(robotgo.U32ToHex(rgb)) + fmt.Println("rgb...", rgbstr) + + hex := robotgo.HexToRgb(uint32(rgb)) + fmt.Println("hex...", hex) + hexh := robotgo.PadHex(robotgo.U8ToHex(hex)) + fmt.Println("HexToRgb...", hexh) // gets the pixel color at 10, 20. color2 := robotgo.GetPixelColor(10, 20) diff --git a/screen/goScreen.h b/screen/goScreen.h index 2078aa1..0e1813e 100644 --- a/screen/goScreen.h +++ b/screen/goScreen.h @@ -34,7 +34,7 @@ char* pad_hex(MMRGBHex color){ static uint8_t rgb[3]; -uint8_t *color_hex_to_rgb(uint32_t h){ +uint8_t* color_hex_to_rgb(uint32_t h){ rgb[0] = RED_FROM_HEX(h); rgb[1] = GREEN_FROM_HEX(h); rgb[2] = BLUE_FROM_HEX(h);