Colour closest to either red, green or blue

Show off your own code here

Colour closest to either red, green or blue

Postby pea » Tue Jun 16, 2009 2:28 pm

When making a macro it's not a good idea to use exact pixel colours as they quite often change slightly. This script 'decides' if a pixel colour is more red, green or blue and should combat the pixel colour changing issue.

Code: Select all
^l::

MouseGetPos, x, y
PixelGetColor, c, x, y

b := c >> 16
g := c >> 8 & 0xff
r := c & 0xff

x := max(max(b, g), r)

If x = %b%
   MsgBox, more blue at %x%x%y%
Else If x = %g%
   MsgBox, more green at %x%x%y%
Else If x = %r%
   MsgBox, more red at %x%x%y%

max(a, b) {
   Return, a > b ? a : b
}
User avatar
pea
Site Admin
 
Posts: 37
Joined: Sat Jun 13, 2009 1:31 pm

Return to Showcase

Who is online

Users browsing this forum: No registered users and 1 guest

cron