HP Prime for All

English  Русский

Author: Edward Shore (original article)

And now for a fun experiment: take a certain function, any functions f(x,y) and g(x,y) where x and y represent the pixels of a calculator screen, and plot their results.

I let x range from 1 to 318 and y range from 1 to 218 and plot the resulting components f(x,y) and g(x,y), respectively, on the screen.

In order to keep all results on the screen, I format the functions like this:

k = f(x,y) MOD 318
j = g(x,y) MOD 218

where pixel coordinate (k,j) gets plotted.

I would like to share some results.

Here is the general format:

// General Format
EXPORT PIX09()
BEGIN LOCAL x, y, j, k, n, l, s;
// set background color
RECT_P(#0h);
// add a counter if necessary
n := 0;
// list colors (if you want more than one colored pixel - optional)
l := {#FF0000h, #87CEEBh, #FFFF00h, #FF00h};
// main loop
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO // next two lines needed if l is defined
n := n+1;
s := 1+n MOD 4;
// k and j represent functions of x and y - they really can be anything
// The MOD 318 and MOD 218 commands are needed to keep the pixels inbound
k := IP((x^2*y)^3 + (x*y^2)^3) MOD 318;
j := IP(e^(x) + e^(y)) MOD 218;
// draw a pixel
PIXON_P(k, j, l(s));
END;
END;
// this just tells the user "I'm done"
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END; Enjoy and try this if you want.

Programs:

EXPORT PIX05()
BEGIN LOCAL x, y, j, k;
RECT_P(#0h);
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO k := IP(√x+√y+√(x*y)) MOD 318;
j := (x^2+y^2+x*y) MOD 218;
PIXON_P(k, j, #87CEEBh);
END;
END;
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END;

This looks like mist: EXPORT PIX09()
BEGIN LOCAL x, y, j, k, n, l, s;
RECT_P(#0h);
n := 0;
l := {#FF0000h, #87CEEBh, #FFFF00h, #FF00h};
// main loop
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO n := n+1;
s := 1+n MOD 4;
k := IP((x^2*y)^3 + (x*y^2)^3) MOD 318;
j := IP(e^(x) + e^(y)) MOD 218;
// draw a pixel
PIXON_P(k, j, l(s));
END;
END;
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END;

This is what TV looked like at light night before Cable and Satellite TV. Yes, I just aged myself. EXPORT PIX10()
BEGIN LOCAL x, y, j, k, n, l, s;
RECT_P(#0h);
n := 0;
l := {#1560BDh, #87CEEBh, #FFFF00h, #9E60h};
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO n := n+1;
s := 1+n MOD 4;
k := IP(e^(x) + 2*e^(y)) MOD 318;
j := IP(2*e^(x) + e^(y)) MOD 218;
PIXON_P(k, j, l(s));
END;
END;
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END; EXPORT PIX11()
BEGIN LOCAL x, y, j, k, n, l, s;
RECT_P(#0h);
n := 0;
l := {#C0C0C0h, #FFFFFFh, #D4AF37h, #FFFF00h};
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO n := n+1;
s := 1+n MOD 4;
k := IP(x-y) MOD 318;
j := IP(−2*e^(x) + .5*e^(y)) MOD 218;
PIXON_P(k, j, l(s));
END;
END;
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END; EXPORT PIX12()
BEGIN LOCAL x, y, j, k, n, l, s;
RECT_P(#4000h);
n := 0;
l := {#FFFF00h, #FF00h, #964B00h, #0h};
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO n := n+1;
s := 1+n MOD 4;
k := IP(x*y) MOD 318;
j := IP(x^2+y^2) MOD 218;
PIXON_P(k, j, l(s));
END;
END;
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END;

Could this be a view of a forest or jungle from a helicopter? EXPORT PIX14()
BEGIN LOCAL x, y, j, k, n, l, s;
RECT_P(#400000h);
n := 0;
l := {#C0C0C0h, #FFFFCCh, #C0C0C0h, #FFFFCCh};
FOR x FROM 1 TO 318 DO FOR y FROM 1 TO 218 DO n := n+1;
s := 1+n MOD 4;
k := IP(21800*SIN(x)) MOD 318;
j := IP(31800*√(y)) MOD 218;
PIXON_P(k, j, l(s));
END;
END;
TEXTOUT_P("DONE", 0, 219, 3, #FFFFFFh);
FREEZE;
END;

This looks like a fabric pattern. 