Hey folks, Zeda here!
I'm primarily an assembly programmer, but I like to implement my algorithms in BASIC to test and optimize. My current project deals with drawing filled circles, ellipses, supercircles (squircles) and superellipses! The TI-BASIC version can draw with pixels ON or OFF and is pretty fast as aside from a couple of multiplications in the overhead code, the main loops just use addition and subtraction!
I've also implemented the filled circle routine in Axe that can be used in BASIC programs (pass a list with coordinates and radius) that can paint pixels ON, OFF, or inverted.
Filled Circle:
;input is a list of 4 elements: {x,y,r,m} where:
; x is the center x coord.
; y is the center y coord.
; r is the radius.
; m is 1 for black or 0 for white.
Ans→L1
Ans(1→H
L1(2→K
abs(L1(3→R
L1(4→B
R→Y
Ans→A
Ymax-ΔY(K-R→S
Ymax-ΔY(K+R→T
Xmin+ΔXH→U
Ans→V
-1→G
R2+1→L
While Y
L-2→L
A-Ans→A
While Ans<0
U+ΔX→U
V-ΔX→V
G+2→G
A+Ans→A
End
Line(U,S,V,S,B
Line(U,T,V,T,B
S-ΔY→S
T+ΔY→T
Y-1→Y
End
Line(U,T,V,T,B
Filled Ellipse:
;input is a list of 5 elements: {x,y,width,height,m} where:
; x is the center x coord.
; y is the center y coord.
; width is the width from the center in pixels.
; height is the height from the center in pixels.
; m is 1 for black or 0 for white.
Ans→L1
Ans(1→H
L1(2→K
abs(L1(3→W
abs(L1(4→D
L1(5→B
Ymax-ΔY(K-D→S
Ymax-ΔY(K+D→T
Xmin+ΔXH→U
Ans→V
D→Y
Ans²→G
W²Y→A
G2→F
W²→M
AnsY→A
Ans2+M→L
M2→M
While Y
L-M→L
A-Ans→A
While Ans<0
U+ΔX→U
V-ΔX→V
A+G→A
G+F→G
End
Line(U,S,V,S,B
Line(U,T,V,T,B
S-ΔY→S
T+ΔY→T
Y-1→Y
End
Line(U,T,V,T,B
Filled Superellipse:
;input is a list of 5 elements: {x,y,width,height,m} where:
; x is the center x coord.
; y is the center y coord.
; width is the width from the center in pixels.
; height is the height from the center in pixels.
; m is 1 for black or 0 for white.
Ans→L1
Ans(1→H
L1(2→K
abs(L1(3→W
abs(L1(4→D
L1(5→B
Ymax-ΔY(K-D→S
Ymax-ΔY(K+D→T
Xmin+ΔXH→U
Ans→V
D→Y
Ans²²→D
Ans14→F
D36→G
D24→P
W²²→W
AnsY.5(4Y²+3Y+1→A
W(4Y³-6Y²+4Y-1→L
W(12Y²-24Y+14→M
W(24Y-36→N
W24→P
While Y
A-L→A
L-M→L
M-N→M
N-W→N
While A<0
U+ΔX→U
V-ΔX→V
A+D→A
D+F→D
F+G→F
G+P→G
End
Line(U,S,V,S,B
Line(U,T,V,T,B
S-ΔY→S
T+ΔY→T
Y-1→Y
End
Line(U,T,V,T,B
Filled Supercircle (Squircle):
;input is a list of 4 elements: {x,y,r,m} where:
; x is the center x coord.
; y is the center y coord.
; r is the radius in pixels.
; m is 1 for black or 0 for white.
Ans→L1
Ans(1→H
L1(2→K
abs(L1(3→R
L1(4→B
Ymax-ΔY(K-R→S
Ymax-ΔY(K+R→T
Xmin+ΔXH→U
Ans→V
R→Y
Ans.5(4R²+3R+1→A
1→G
2→F
-12→E
6R²→M
4R³-Ans+4R-1→L
2M-24R+14→M
24R-36→N
While Y
A-L→A
L-M→L
M-N→M
N-24→N
While A<0
U+ΔX→U
V-ΔX→V
A+G→A
E+24→E
Ans+F→F
Ans+G→G
End
Line(U,S,V,S,B
Line(U,T,V,T,B
S-ΔY→S
T+ΔY→T
Y-1→Y
End
Line(U,T,V,T,B
I came up with these algorithms on my own, too! I later learned that the circle code was either a rehash of the famous Bresenham method or at the least pretty similar. Believe it or not, I came up with the circle (and related code) before I ever made a working line algorithm. That's because whereas I sucked at graphics, I was working on developing a factoring algorithm (which I now know to be Fermat factoring!) and I had a stroke of insight into a circle algorithm which I immediately included in one of the first versions of Grammer.
Anyways, the BASIC codes might not be optimal for TI-BASIC, I haven't tested it, but they were designed for assembly-level integer arithmetic. They aren't super fast, but all are welcome to use them. In particular, I think the superellipse routine is cool and Wikipedia says that iOS uses squircles for their icons.
(Hopefully not too many typos)