Programs will follow. Enjoy! Eddie

DRAW3DCUBE |

DRAW3DCYN |

DRAW3DSPH |

DRAW3DWAVE: I wanted something to be drawn using a sine wave.

DRAW3DWAVE |

DRAWSUNSET - This is probably my favorite, since I like sunsets.

DRAWSUNSET |

Tip: The HP Prime screen is 318 pixels wide and 240 pixels deep. If you want to leave room for custom menus, then the canvas is 318 pixels by 218 pixels. The x axis increases to the right, but unlike the Cartesian plane, the y axis increases downward instead of upward.

Eddie

-------------

Programs:

**DRAW3DCUBE**

EXPORT DRAW3DCUBE()

BEGIN

LOCAL t,a,b,c,d,s;

RECT();

// coord

a:=159-50*COS(45°);

b:=109-50*SIN(45°);

c:=159+50*COS(45°)+1;

d:=159-50*SIN(45°);

// drawing

LINE_P(a+50*COS(45°),b-SIN(45°),a,b);

LINE_P(a,b,159,109);

LINE_P(159,109,c,b);

LINE_P(c,b,a+50*COS(45°),b-SIN(45°));

LINE_P(a,b,a,d);

LINE_P(a,d,159,159);

LINE_P(159,159,159,109);

LINE_P(159,159,c,d);

LINE_P(c,d,c,b);

// left/right side shade

FOR t FROM b TO d DO

LINE_P(a,t,159,t+50*SIN(45°),#FF0000h);

LINE_P(c,t,159,t+50*SIN(45°),#FFh);

END;

// top shade

FOR t FROM 1 TO 50 DO

LINE_P(a+t*COS(45°),b-t*SIN(45°),

a+t*COS(45°),b+t*SIN(45°),#FFFF00h);

END;

FOR t FROM 50 DOWNTO 1 DO

LINE_P(c-t*COS(45°),b-t*SIN(45°),

c-t*COS(45°),b+t*SIN(45°),#FFFF00h);

END;

WAIT(0); // I prefer WAIT(0) to FREEZE;

END;

**DRAW3DCYN**

EXPORT DRAW3DCYN()

BEGIN

LOCAL t;

HAngle:=0;

RECT();

// cylinder shell

FOR t FROM 0 TO 100 STEP 1 DO

ARC_P(159,70+t,20,0,π,#7DF9FFh);

ARC_P(159,70+t,20,π,2*π,#1560BDh);

END;

// sides

LINE_P(139,70,139,170,#1560BDh);

LINE_P(179,70,179,170,#1560BDh);

ARC_P(159,70,20,0,2*π,#1560BDh);

WAIT(0);

END;

**DRAW3DSPH**

EXPORT DRAW3DSPH()

BEGIN

// 2015-01-22

LOCAL t;

RECT();

// sphere loop

FOR t FROM 100 DOWNTO 1 DO

ARC_P(159,109,t,0,2*π,#808080h);

END;

// outside

FOR t FROM 59 TO 259 DO

PIXON_P(t,−.0025*t^2+.795*t+70.975);

END;

WAIT(0);

END;

**DRAW3DWAVE**

EXPORT DRAW3DWAVE()

BEGIN

LOCAL t,a,b;

RECT();

HAngle:=0;

FOR t FROM 0 TO 318 DO

a:=25*SIN(3.95168887244ᴇ−2*t-π)+100;

b:=a+25;

PIXON_P(t,a,#FFh);

PIXON_P(t,b,#FFh);

LINE_P(t,a+1,t,b-1,#87CEEBh);

LINE_P(t,b+1,t,218,#964B00h);

END;

LINE_P(0,100,0,125,#FFh);

LINE_P(318,100,318,125,#FFh);

LINE_P(0,125,0,218,#D4AF37h);

LINE_P(318,125,318,218,#D4AF37h);

LINE_P(0,218,318,218,#D4AF37h);

WAIT(0);

END;

**DRAWSUNSET**

EXPORT DRAWSUNSET()

BEGIN

RECT(#87CEEBh);

LOCAL t,a,b;

HAngle:=0;

// sun

FOR t FROM 50 DOWNTO 40 DO

ARC_P(159,109,t,0,2*π,#FFA500h);

END;

FOR t FROM 40 DOWNTO 0 DO

ARC_P(159,109,t,0,2*π,#FFFF00h);

END;

// horizon

LINE_P(0,108,318,108);

// ground and water

FOR t FROM 0 TO 159 DO

a:=1.855525955687ᴇ−4*t^3

-5.05717802449ᴇ−2*t^2

+3.67070350319*t+109;

LINE_P(t,a,t,109,#80h);

LINE_P(t,a+1,t,242,#964B00h);

END;

FOR t FROM 159 TO 318 DO

a:=1.23858063728ᴇ−4*t^3

-9.61799073419ᴇ−2*t^2

+23.6382711212*t

-1664.83052851;

LINE_P(t,a,t,109,#80h);

LINE_P(t,a+1,t,242,#964B00h);

END;

// lines

LINE_P(120,111,188,111,#C0C0C0h);

LINE_P(125,113,183,113,#C0C0C0h);

LINE_P(130,115,178,115,#C0C0C0h);

LINE_P(135,117,173,117,#C0C0C0h);

WAIT(0);

END;

This blog is property of Edward Shore. 2015

## No comments:

## Post a Comment