How to resolve the algorithm Color of a screen pixel step by step in the Action! programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Color of a screen pixel step by step in the Action! programming language
Table of Contents
Problem Statement
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Color of a screen pixel step by step in the Action! programming language
Source code in the action! programming language
PROC Main()
BYTE POINTER ptr
BYTE
w=[160],h=[160],x=[0],y=[0],c,k,update=[1],
CH=$02FC ;Internal hardware value for last key pressed
CARD size=[6400],i
Graphics(15) ;Graphics 160x160 with 4 colors with text window
ptr=PeekC(88)
; Fill screen with random colors
FOR i=1 TO size
DO
ptr^=Rand(0)
ptr==+1
OD
PrintE("Use arrow keys to change position and Esc to exit.")
DO
IF update THEN
c=Locate(x,y)
PrintF("x=%B y=%B c=%B%E",x,y,c)
FI
k=CH
CH=$FF
update=1
IF k=134 THEN
IF x=0 THEN x=w-1
ELSE x==-1 FI
ELSEIF k=135 THEN
IF x=w-1 THEN x=0
ELSE x==+1 FI
ELSEIF k=142 THEN
IF y=0 THEN y=h-1
ELSE y==-1 FI
ELSEIF k=143 THEN
IF y=h-1 THEN y=0
ELSE y==+1 FI
ELSEIF k=28 THEN
EXIT
ELSE
update=0
FI
OD
RETURN
You may also check:How to resolve the algorithm Arithmetic-geometric mean/Calculate Pi step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Read a file character by character/UTF8 step by step in the BASIC256 programming language
You may also check:How to resolve the algorithm Achilles numbers step by step in the Wren programming language
You may also check:How to resolve the algorithm Stack traces step by step in the VBA programming language
You may also check:How to resolve the algorithm Hash from two arrays step by step in the Fantom programming language