Code: Select all
00 { 115-Byte Prgm }
01▸LBL "Fline"
02 "↓•••↓"
03 RCL "R1"
04 RCL "C1"
05 AGRAPH
06 RCL "R2"
07 RCL "R1"
08 -
09 STO "RS"
10 ABS
11 RCL "C2"
12 RCL "C1"
13 -
14 STO "CS"
15 ABS
16 X<Y?
17 X<>Y
18 X=0?
19 RTN
20 STO÷ "RS"
21 STO÷ "CS"
22 IP
23 STO "ST"
24 RCL "RS"
25 RCL "CS"
26 RCL "R1"
27 RCL "C1"
28▸LBL 00
29 RCL+ ST Z
30 X<>Y
31 RCL+ ST T
32 X<>Y
33 AGRAPH
34 DSE "ST"
35 GTO 00
36 CLV "RS"
37 CLV "CS"
38 CLV "ST"
39 END
At the start of the program, in Line 02, a bitmap pattern is defined, which is a 5x5 square without the corners, but you can enter any bitmap pattern you wish. You could even remove it completely, and have the calling program defining the bitmap.
The program draws the pattern starting from C1,R1 to C2,R2 by plotting the bitmap pattern in pixel sized increments.
The actual code drawing the line, beginning at LBL 00, is only 8 instructions long, and mostly uses the stack. I dont think this can be much improved.
You can also make it draw pixel thin lines by replacing the AGRAPH instructions in line 5 and 33 with PIXEL.
It does not check if it is outside the screen.
I have also enclosed a demo program, FDEMO, which draws a polygon with the number of corners defined by the number in stack register X.
It draws all lines possible between the corners.
Here is the code for the demo:
Code: Select all
00 { 117-Byte Prgm }
01▸LBL "FDEMO"
02 STO 00
03 360
04 X<>Y
05 ÷
06 STO 02
07 1ᴇ-3
08 STO+ 00
09▸LBL 00
10 RCL 00
11 IP
12 1
13 -
14 STO 01
15 RCL 00
16 RCL 02
17 ×
18 STO 03
19 SIN
20 100
21 ×
22 200
23 +
24 STO "C1"
25 RCL 03
26 COS
27 100
28 ×
29 120
30 +
31 STO "R1"
32▸LBL 01
33 RCL 01
34 RCL 02
35 ×
36 STO 03
37 SIN
38 100
39 ×
40 200
41 +
42 STO "C2"
43 RCL 03
44 COS
45 100
46 ×
47 120
48 +
49 STO "R2"
50 XEQ "Fline"
51 DSE 01
52 GTO 01
53 DSE 00
54 GTO 00
55 END
Here are the programs if you wish to download them: