Anonymous user
Color of a screen pixel: Difference between revisions
Added a Color type. Fixed an error in the way to find the color (dereferencing was at the wrong place).
(→{{header|Wren}}: A bit simpler.) |
(Added a Color type. Fixed an error in the way to find the color (dereferencing was at the wrong place).) |
||
Line 686:
{{libheader|GTK2}}
<lang nim>import gtk2, gdk2, gdk2pixbuf
type Color = tuple[r, g, b: byte]
gtk2.nim_init()
proc getPixelColor(x, y: int32):
var p = pixbufNew(COLORSPACE_RGB, false, 8, 1, 1)
discard p.getFromDrawable(getDefaultRootWindow().Drawable,
getDefaultScreen().getSystemColormap(), x, y, 0, 0, 1, 1)
result = cast[
echo getPixelColor(0, 0)</lang>
|