Color Demonstration
05-10-2018, 02:32 PM
Post: #1 Eddie W. Shore Senior Member Posts: 979 Joined: Dec 2013
Color Demonstration  https://edspi31415.blogspot.com/2018/05/...ation.html

Introduction

The HP Prime program PENTCOLOR allows the cycler to through colors with the touch of the following buttons:

Key [ 1 ]: Red
Key [ 2 ]: Green
Key [ 3 ]: Blue

Each color setting cycles through the values of 0, 64, 128, 192, and 255. Exit the program with the Escape key ( [ Esc ] ). This program allows the user to cycle through different colors using RGB values.

I use two subroutines in PENTCOLOR. The first draws the text every time the key is selected, which allows for crisp text. The second is for value calculation. In subroutines on the HP Prime, all variables that are used must be local. Global variables are passed through the subroutine arguments.

HP Prime Program: PENTCOLOR
Code:

SBR1(); // sub routine text
// allows for crisp text

SBR2(); // sub routine calc
// saves space in main program

// main program
EXPORT PENTCOLOR()
BEGIN
// EWS 2018-05-07

LOCAL K,R,G,B;
// R,G,B are set at 0
RECT();

2. Green, 3. Blue",0,20,4);

REPEAT
K:=GETKEY;

// Key 1, red
IF K==42 THEN
RECT();
R:=SBR2(R);
SBR1(R,G,B);
END;

// Key 2, green
IF K==43 THEN
RECT();
G:=SBR2(G);
SBR1(R,G,B);
END;

// Key 3, blue
IF K==44 THEN
RECT();
B:=SBR2(B);
SBR1(R,G,B);
END;

UNTIL K==4; // ESC key

END;

// sub routines
// all subroutines have
// all local variables
SBR1(x,y,z)
BEGIN
TEXTOUT_P("[ 1 ]: Red: "+x,
0,20,4,#FF0000h);
TEXTOUT_P("[ 2 ]: Green: "+y,
0,40,4,#00FF00h);
TEXTOUT_P("[ 3 ]: Blue: "+z,
0,60,4,#0000FFh);
TEXTOUT_P("[Esc]: Exit",
0,120,4);
// draw box
FILLPOLY_P({(160,20),(310,20),
(310,170),(160,170)},RGB(x,y,z));
END;

SBR2(t)
BEGIN
t:=t+64;
IF t==256 THEN t:=255; END;
IF t==319 THEN t:=0; END;
RETURN t;
END;
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)