Graphic performance test #1/3 : NumWorks (Python) vs HP Prime (Python-like)
Mandelbrot fractal using complex numbers in Python.
NumWorks (v1.2.0) and HP Prime (v13011) comparison.
NumWorks code in Python (firmware 1.2.0+) :
import kandinsky
def mandelbrot(W,H,N) :
for x in range(W):
for y in range(H):
z=complex(0,0)
c=complex(2.7*x/(W-1)-2.1,-(1.87*y/(H-1)-.935))
j=0
while j {less than} N and abs(z) {less than} 2:
j=j+1
z=z*z+c
t=255*j/N
kandinsky.set_pixel(x,y,kandinsky.color(int(t),int(.75*t),int(.25*t)))
HP Prime code in Python-like (firmware 12951+) :
#cas
def fractal_python(W,H,N) :
local x,y,z,c,j,t
for x in range(W):
for y in range(H):
z=0
c=2.7*x/(W-1)-2.1-i*(1.87*y/(H-1)-.935)
j=0
while j {less than} N and abs(z) {less than} 2:
j=j+1
z=z*z+c
t=255*j/N
PIXON_P(x,y,RGB(IP(t),IP(.75*t),IP(.25*t)))
FREEZE
WAIT(0)
#end