Color of a screen pixel: Difference between revisions
Content added Content deleted
(Added Wren) |
(→{{header|Wren}}: A bit simpler.) |
||
Line 1,034:
=={{header|Wren}}==
{{libheader|DOME}}
<lang ecmascript>import "dome" for Window, Process
import "graphics" for Canvas, Color
import "input" for Mouse
class Game {
static init() {
Window.title = "Color of a screen pixel"
Canvas.cls(Color.orange) // {255, 163, 0} in the default palette▼
}
static update() {
// when the left button is first pressed
static draw(dt) {▼
if (Mouse.isButtonPressed("left")) {
▲ Canvas.cls(Color.orange) // {255, 163, 0} in the default palette
▲ // report initial location and color of pixel at mouse cursor
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))")
}
}
▲ static draw(dt) {}
static getRGB(col) { "{%(col.r), %(col.g), %(col.b)}" }
Line 1,067 ⟶ 1,065:
<pre>
$ ./dome color_of_screen_pixel.wren
The color of the pixel at (
</pre>
|