Color of a screen pixel: Difference between revisions
Content deleted Content added
m Phix/pGUI |
Added Wren |
||
Line 1,031:
puts [format "pixel at mouse: (%d,%d,%d)" \
{*}[getPixelAtPoint {*}[winfo pointerxy .]]]</lang>
=={{header|Wren}}==
{{libheader|DOME}}
<lang ecmascript>import "dome" for Window
import "graphics" for Canvas, Color
import "input" for Mouse
var Reported = false
class Game {
static init() {
Window.title = "Color of a screen pixel"
}
static update() {}
static draw(dt) {
Canvas.cls(Color.orange) // {255, 163, 0} in the default palette
// report initial location and color of pixel at mouse cursor
if (!Reported) {
var x = Mouse.x
var y = Mouse.y
var col = Canvas.pget(x, y)
System.print("The color of the pixel at (%(x), %(y)) is %(getRGB(col))")
Reported = true
}
}
static getRGB(col) { "{%(col.r), %(col.g), %(col.b)}" }
}</lang>
{{out}}
Sample output:
<pre>
$ ./dome color_of_screen_pixel.wren
The color of the pixel at (141, 138) is {255, 163, 0}
</pre>
=={{header|XPL0}}==
|