Color of a screen pixel: Difference between revisions
Content added Content deleted
(→{{header|Tcl}}: + Standard ML) |
(→{{header|Python}}: Added parenthesis to print to make examples python3 compatible (hopefully), minor fixes) |
||
Line 755: | Line 755: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{libheader|PyWin32}} |
{{libheader|PyWin32}} |
||
{{works_with|Windows}} |
|||
<lang python>def get_pixel_colour(i_x, i_y): |
<lang python>def get_pixel_colour(i_x, i_y): |
||
import win32gui |
import win32gui |
||
Line 764: | Line 765: | ||
return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff) |
return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff) |
||
print get_pixel_colour(0, 0)</lang> |
print (get_pixel_colour(0, 0))</lang> |
||
{{libheader|PIL}} |
{{libheader|PIL}} |
||
{{works_with|Windows}} |
{{works_with|Windows}} |
||
<lang python>def get_pixel_colour(i_x, i_y): |
<lang python>def get_pixel_colour(i_x, i_y): |
||
import PIL.ImageGrab |
import PIL.ImageGrab |
||
return PIL.ImageGrab.grab().load()[i_x, i_y] |
return PIL.ImageGrab.grab().load()[i_x, i_y] |
||
print get_pixel_colour(0, 0)</lang> |
print (get_pixel_colour(0, 0))</lang> |
||
{{libheader|PIL}} |
{{libheader|PIL}} |
||
{{libheader|python-xlib}} |
{{libheader|python-xlib}} |
||
Line 786: | Line 787: | ||
return tuple(map(int, lf_colour)) |
return tuple(map(int, lf_colour)) |
||
print get_pixel_colour(0, 0)</lang> |
print (get_pixel_colour(0, 0))</lang> |
||
{{libheader|PyGTK}} |
{{libheader|PyGTK}} |
||
<lang python>def get_pixel_colour(i_x, i_y): |
<lang python>def get_pixel_colour(i_x, i_y): |
||
Line 794: | Line 795: | ||
return tuple(o_gdk_pixbuf.get_pixels_array().tolist()[0][0]) |
return tuple(o_gdk_pixbuf.get_pixels_array().tolist()[0][0]) |
||
print get_pixel_colour(0, 0)</lang> |
print (get_pixel_colour(0, 0))</lang> |
||
{{libheader|PyQt}} |
{{libheader|PyQt}} |
||
<lang python>def get_pixel_colour(i_x, i_y): |
<lang python>def get_pixel_colour(i_x, i_y): |
||
Line 804: | Line 805: | ||
return ((i_colour >> 16) & 0xff), ((i_colour >> 8) & 0xff), (i_colour & 0xff) |
return ((i_colour >> 16) & 0xff), ((i_colour >> 8) & 0xff), (i_colour & 0xff) |
||
print get_pixel_colour(0, 0)</lang> |
print (get_pixel_colour(0, 0))</lang> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |