'A = render anti-aliased image
'B = render standard image
'MouseButton1 = Re-center
'MouseButton3 = Zoom x2 (in)
'MouseButton2 = Zoom /2 (out)
'Leftarrow = Next example plot
'Rightarrow = Previous example plot
'Uparrow = Increase iterations (where applicable)
'DownArrow = Decrease iterations (where applicable)
'Num 1 = Shading option (HSV vs RGB vs Average)
'Num 2 = Shading scheme (1, 2, 3)
'Num 3 = Shade near origin
'Num 4 = Shade axes
'Num 5 = Shade integers
'Num 6 = Shade contours
'Num 7 = Greyscale
'Num 8 = Stencil
'Num 9 = Invert
'Num 0 = Bolden
'SCREEN _NEWIMAGE(250, 250, 32)
'SCREEN _NEWIMAGE(1024, 768, 32)
'SCREEN _NEWIMAGE(1920, 1080, 32)
PlotOption(0) = 10
PlotOption(1) = .5
PlotOption(2) = 1
PlotOption(3) = 1
PlotOption(4) = 1
PlotOption(5) = 1
PlotOption(6) = 1
PlotOption(7) = -1
PlotOption(8) = -1
PlotOption(9) = -1
PlotOption(10) = -1
' Selector
q = 1
Initialize q, ExhibitName, zoom, xshift, yshift
CALL DrawPlot
(ExhibitName
, zoom
, xshift
, yshift
, -1)
' User interaction
Calculate re, im, ExhibitName
'LOCATE 5, 1: PRINT "re: "; INT(re + .5); " "
'LOCATE 6, 1: PRINT "im: "; INT(im + .5); " "
ReDraw = -1
zoom = zoom * 1 / 2
ReDraw = -1
zoom = zoom * 2
ReDraw = -1
ReDraw = 1
ReDraw = -1
PlotOption(1) = PlotOption(1) + .5
IF ((PlotOption
(1) > 1)) THEN PlotOption
(1) = 0 ReDraw = -1
PlotOption(2) = PlotOption(2) + 1
IF (PlotOption
(2) > 4) THEN PlotOption
(2) = 1 ReDraw = -1
IF (kh
= ASC("3")) THEN PlotOption
(3) = -PlotOption
(3): ReDraw
= -1 IF (kh
= ASC("4")) THEN PlotOption
(4) = -PlotOption
(4): ReDraw
= -1 IF (kh
= ASC("5")) THEN PlotOption
(5) = -PlotOption
(5): ReDraw
= -1 IF (kh
= ASC("6")) THEN PlotOption
(6) = -PlotOption
(6): ReDraw
= -1 IF (kh
= ASC("7")) THEN PlotOption
(7) = -PlotOption
(7): ReDraw
= -1 IF (kh
= ASC("8")) THEN PlotOption
(8) = -PlotOption
(8): ReDraw
= -1 IF (kh
= ASC("9")) THEN PlotOption
(9) = -PlotOption
(9): ReDraw
= -1 IF (kh
= ASC("0")) THEN PlotOption
(10) = -PlotOption
(10): ReDraw
= -1 q = q + 1
Initialize q, ExhibitName, zoom, xshift, yshift
ReDraw = -1
q = q - 1
Initialize q, ExhibitName, zoom, xshift, yshift
ReDraw = -1
PlotOption(0) = PlotOption(0) + 1
ReDraw = -1
PlotOption(0) = PlotOption(0) - 1
IF (PlotOption
(0) < 0) THEN PlotOption
(0) = 0 ReDraw = -1
CALL DrawPlot
(ExhibitName
, zoom
, xshift
, yshift
, ReDraw
) ReDraw = 0
xshift = 0
yshift = 0
zoom = 50 * 2
ExhibitName = "Vanilla"
ExhibitName = "Monomial"
ExhibitName = "Pole"
ExhibitName = "Shifts"
ExhibitName = "Geometric Series"
PlotOption(0) = 5
ExhibitName = "Taylor"
PlotOption(0) = 10
ExhibitName = "Exponential"
ExhibitName = "Logarithm"
ExhibitName = "Sqrt"
ExhibitName = "Branch"
ExhibitName = "Cosine"
ExhibitName = "Sine"
ExhibitName = "Gamma"
ExhibitName = "Condenser"
ExhibitName = "Inductor"
ExhibitName = "Mandelbrot"
xshift = -.5 - .25
PlotOption(0) = 1
ExhibitName = "Julia"
PlotOption(0) = 8
ExhibitName = "CIF1"
PlotOption(0) = 10
ExhibitName = "CIF2"
PlotOption(0) = 50
ExhibitName = "CIF3"
ExhibitName = "Canonical Logarithm"
DIM AS DOUBLE re
, im
, u
, v
, u0
, v0
, uu
, vv
, fu
, fv
, xx
, yy
, p
, q
, t
re = x
im = y
're = x ^ 2 - y ^ 2
'im = 2 * x * y
'cexp re, im, x, y, 2, 0
cexp re, im, x, y, 3, 0
'cexp re, im, x, y, -1, 0
cexp re, im, x, y, -2, 0
'cdiv u, v, x + 1, y, x - 1, y
cdiv u, v, x, y, x - 1, y
re = u
im = v
p = 0
q = 0
u = 1
v = 0
cadd u0, v0, p, q, u, v
FOR m
= 1 TO PlotOption
(0) cexp uu, vv, x, y, m, 0
cadd p, q, u0, v0, uu, vv
u0 = p
v0 = q
re = u0
im = v0
p = 0
q = 0
u = 1
v = 0
cadd u0, v0, p, q, u, v
FOR m
= 1 TO PlotOption
(0) cexp uu, vv, x, y, m, 0
cdiv u, v, uu, vv, facto&(m), 0
cadd p, q, u0, v0, u, v
u0 = p
v0 = q
re = u0
im = v0
cexp re
, im
, EXP(1), 0, x
, y
clog re, im, x, y
cexp re, im, x, y, 1 / 2, 0
cdiv p, q, x + 2, y + 1, x - 2, y - 1
clog re, im, p, q
cosz re, im, x, y
sinz re, im, x, y
' Is this right?
uu = x - y
vv = x + y
cgamma uu, vv, x, y
re = uu
im = vv
re = 1
im = 0
cmul u, v, 1, 0, -0.1 * (j - 3.5), 0
cmul re, im, re, im, x - u, y - v - 0.1
cdiv re, im, re, im, x - u, y - v + 0.1
re = 1
im = 0
cmul u, v, 1, 0, 0, -0.18 * (j - 2.5)
cmul re, im, re, im, x - u - 0.2, y - v
cdiv re, im, re, im, x - u + 0.2, y - v + 0.1
u = x
v = y
FOR m
= 0 TO PlotOption
(0) '2 '5 '00 u0 = u
v0 = v
u = u0 ^ 2 - v0 ^ 2 + x
v = 2 * u0 * v0 + y
re = u
im = v
u = x
v = y
FOR m
= 0 TO PlotOption
(0) u0 = u
v0 = v
u = u0 ^ 2 - v0 ^ 2 + 0.35
v = 2 * u0 * v0 + 0 '0.5
re = u
im = v
' Riemann sum resolution
n = PlotOption(0) '25
xx = 0
yy = 0
' Integration contour
' 1:
'u = 3 * (2 * COS(j * 2 * pi / n))
'v = 3 * (2 * SIN(j * 2 * pi / n))
' 2:
u
= 4 * (2 * COS(j
* 2 * pi
/ n
)) v
= 4 * (2 * SIN(j
* 2 * pi
/ n
) * COS(j
* 2 * pi
/ n
))
' f(z)
fu = u - v 'u ^ 2 - v ^ 2
fv = u + v '2 * u * v
' f(z) / (z - z_0)
cdiv uu, vv, fu, fv, u - x, v - y
' z'(t) = derivative of integration contour
' 1:
'cmul re, im, uu, vv, 3 * (-2 * SIN(j * 2 * pi / n)), 3 * (2 * COS(j * 2 * pi / n))
' 2:
cmul re
, im
, uu
, vv
, 4 * (-2 * SIN(j
* 2 * pi
/ n
)), 4 * (2 * COS(j
* 4 * pi
/ n
))
' Integral height calculation
xx = xx + 0.5 * re
yy = yy + 0.5 * im
xx = xx + re
yy = yy + im
' Integral base calculation
xx = xx * 2 * pi / n
yy = yy * 2 * pi / n
' Rescale by 1/(2*pi*i)
cmul re, im, xx, yy, 0, -1 / (2 * pi)
' Riemann sum resolution
n = PlotOption(0) '10
xx = 0
yy = 0
xr = 2.0
xi = 0.0
' Integration contour
u
= 3 * 3 * COS(j
* 2 * pi
/ n
) v
= 3 * 2 * SIN(j
* 2 * pi
/ n
)
' f(z)
sinz fu, fv, u, v
' f(z) / (z - z_0)^(xr + i xi)
p = u - x
q = v - y
cexp p, q, p, q, xr, xi
cdiv uu, vv, fu, fv, p, q
' z'(t) = derivative of integration contour
cmul re
, im
, uu
, vv
, 3 * -3 * SIN(j
* 2 * pi
/ n
), 2 * COS(j
* 2 * pi
/ n
)
' Integral height calculation
xx = xx + 0.5 * re
yy = yy + 0.5 * im
xx = xx + re
yy = yy + im
' Integral base calculation
xx = xx * 2 * pi / n
yy = yy * 2 * pi / n
' rescale by Gamma(xr + i ri)/(2*pi*i)
cgamma u, v, xr + 1, xi
cmul re, im, xx, yy, u, v
cmul re, im, re, im, 0, -1 / (2 * pi)
xx = 0
yy = 0
cexp p
, q
, EXP(1), 0, uu
, vv
cdiv u0, v0, p, q, uu - x, vv - y
cmul p
, q
, u0
, v0
, COS(5 * t
) - 5 * t
* SIN(5 * t
), SIN(5 * t
) + 5 * t
* COS(5 * t
) xx = xx + 0.5 * p
yy = yy + 0.5 * q
xx = xx + 1 * p
yy = yy + 1 * q
xx = xx * 0.01
yy = yy * 0.01
cmul re, im, xx, yy, 0, -1 / (2 * pi)
CASE "Canonical Logarithm" a0 = .5
k0 = 0.09
sx0 = 2
sy0 = 1
tx0
= a0
* EXP(k0
* 16) * COS(16) + sx0
ty0
= a0
* EXP(k0
* 16) * SIN(16) + sy0
re = 0
im = 0
p
= a0
* EXP(k0
* t
) * COS(t
) + sx0
- tx0
q
= a0
* EXP(k0
* t
) * SIN(t
) + sy0
- ty0
cdiv uu, vv, 1, 0, p - x, q - y
cmul xx
, yy
, uu
, vv
, a0
* EXP(k0
* t
) * (k0
* COS(t
) - SIN(t
)), a0
* EXP(k0
* t
) * (k0
* SIN(t
) + COS(t
)) re = re + xx
im = im + yy
p
= -a0
* EXP(k0
* t
) * COS(t
) - sx0
+ tx0
q
= -a0
* EXP(k0
* t
) * SIN(t
) - sy0
+ ty0
cdiv uu, vv, 1, 0, p - x, q - y
cmul xx
, yy
, uu
, vv
, a0
* EXP(k0
* t
) * (k0
* COS(t
) - SIN(t
)), a0
* EXP(k0
* t
) * (k0
* SIN(t
) + COS(t
)) re = re + xx
im = im + yy
re = re * 0.1
im = im * 0.1
cmul uu, vv, re, im, 0, -1 / (2 * pi)
re = uu
im = vv
x = re
y = im
r
= SQR(re
* re
+ im
* im
)
' Color scheme 0
a
= (pi
+ _ATAN2(im
, -re
)) / (2 * pi
) c1~& = hrgb~&(a, r)
' Color scheme 1
h = 180 + a * 180 / pi
k = 50 * r
k
= 50 * LOG(1 + r
* zoom
) k
= 50 * LOG(1 + r
) * (1 + r
) k = 50 * r / zoom
'IF (r < 1) THEN
'ELSE
'END IF
s
= 50 + ((k
* 1) MOD 50) c2~& = HSVtoRGB~&(h, s, 100)
' Weighted average of color schemes
c0~& = ShadeBlend(PlotOption(1), c1~&, c2~&)
c0~& = SetAlpha(c0~&, 255)
'IF ((re > 0) AND (im > 0)) THEN
' Origin
IF (PlotOption
(3) = 1) THEN c0~&
= ShadeOrigin
(c0~&
, re
, im
, 0.075, 100)
' Axes
IF (PlotOption
(4) = 1) THEN c0~&
= ShadeAxes
(c0~&
, re
, im
, 0.075, 100)
' Integers
IF (PlotOption
(5) = 1) THEN c0~&
= ShadeIntegers
(c0~&
, re
, im
, 0.075, 100)
'END IF
' Contours
IF (PlotOption
(6) = 1) THEN c0~&
= ShadeContours
(c0~&
, k
, 50, 2, 100)
' Greyscale
IF (PlotOption
(7) = 1) THEN c0~&
= ShadeGreyscale
(c0~&
)
' Stencil
IF (PlotOption
(8) = 1) THEN c0~&
= ShadeStencil
(c0~&
, 100)
' Invert
IF (PlotOption
(9) = 1) THEN c0~&
= ShadeInvert
(c0~&
)
' Bolden
IF (PlotOption
(0) = 1) THEN c0~&
= ShadeBolden
(c0~&
, .8)
DIM AS DOUBLE j
, k
, x0
, y0
, re
, im
, red
, grn
, blu
, alf
, nr
, ng
, nb
, na
, d
, f
, jj
, kk
re = x0 / zoom + xshift
im = y0 / zoom + yshift
Calculate re, im, TheExhibit
ShadePixel red, grn, blu, alf, re, im, zoom
f = 2
d = .25
ii = 0
ii = ii + 1
re = x0 / zoom + xshift
im = y0 / zoom + yshift
Calculate re, im, TheExhibit
ShadePixel red, grn, blu, alf, re, im, zoom
r(ii) = red
g(ii) = grn
b(ii) = blu
a(ii) = alf
w
(ii
) = EXP(-1 * ((j
- jj
) ^ 2 + (k
- kk
) ^ 2)) red = 0
grn = 0
blu = 0
alf = 0
nr = 0
ng = 0
nb = 0
na = 0
red = red + r(jj) * w(ii)
grn = grn + g(jj) * w(ii)
blu = blu + b(jj) * w(ii)
alf = alf + a(jj) * w(ii)
nr = nr + w(ii)
ng = ng + w(ii)
nb = nb + w(ii)
na = na + w(ii)
red = red / nr
grn = grn / ng
blu = blu / nb
alf = alf / na
CALL CPset
(x0
, y0
, _RGBA(red
, grn
, blu
, alf
))
'COLOR _RGB32(255, 255, 255, 255)
'LOCATE 1, 1: PRINT TheExhibit
'LOCATE 2, 1: PRINT "zoom: "; zoom
'LOCATE 3, 1: PRINT "xshift: "; xshift
'LOCATE 4, 1: PRINT "yshift: "; yshift
ShadeBlend~&
= _RGB32(red
, grn
, blu
, alf
)
ShadeContours~& = c
IF (((INT(x
) + 1 - x
) < z
) AND ((INT(x
) + 1) <> 0)) THEN c
= SetAlpha
(c
, a
) IF (((INT(y
) + 1 - y
) < z
) AND ((INT(y
) + 1) <> 0)) THEN c
= SetAlpha
(c
, a
) ShadeIntegers~& = c
ShadeAxes~& = c
ShadeOrigin~& = c
red = 0
grn = 0
blu = 0
ShadeStencil~&
= _RGB32(red
, grn
, blu
, 255)
IF ((red
+ grn
+ blu
) < (3 * 255)) THEN red = red * t
grn = grn * t
blu = blu * t
PRINT "Out of range:"; h; s; v
s = s / 100
v = v / 100
c = s * v
x
= c
* (1 - ABS(fmod
(h
/ 60, 2) - 1)) m = v - c
r = c
g = x
b = 0
r = x
g = c
b = 0
r = 0
g = c
b = x
r = 0
g = x
b = c
r = x
g = 0
b = c
r = c
g = 0
b = x
r = (r + m) * 255
g = (g + m) * 255
b = (b + m) * 255
fmod##
= numer
- INT(numer
/ denom
) * denom
' a vince original, slightly modified
r
= 0.5 - 0.5 * SIN(2 * pi
* h
- pi
/ 2) g
= (0.5 + 0.5 * SIN(2 * pi
* h
* 1.5 - pi
/ 2)) * -(h
< 0.66) b
= (0.5 + 0.5 * SIN(2 * pi
* h
* 1.5 + pi
/ 2)) * -(h
> 0.33) mm
= 0 * (m
* 500 MOD 500) n = 16
rr = 255 * r - 0.15 * mm - 35 * p
gg = 255 * g - 0.15 * mm - 35 * p
bb = 255 * b - 0.15 * mm - 35 * p
hrgb~&
= _RGB(rr
, gg
, bb
)
'SUB circlef (x AS LONG, y AS LONG, r AS LONG, c AS LONG)
' DIM AS LONG xx, yy, e
' xx = r
' yy = 0
' e = -r
' DO WHILE (yy < xx)
' IF (e <= 0) THEN
' yy = yy + 1
' LINE (x - xx, y + yy)-(x + xx, y + yy), c, BF
' LINE (x - xx, y - yy)-(x + xx, y - yy), c, BF
' e = e + 2 * yy
' ELSE
' LINE (x - yy, y - xx)-(x + yy, y - xx), c, BF
' LINE (x - yy, y + xx)-(x + yy, y + xx), c, BF
' xx = xx - 1
' e = e - 2 * xx
' END IF
' LOOP
' LINE (x - r, y)-(x + r, y), c, BF
'END SUB
x = xx
y = yy
a = aa
b = bb
u = x + a
v = y + b
x = xx
y = yy
a = aa
b = bb
u = x * a - y * b
v = x * b + y * a
x = xx
y = yy
a = aa
b = bb
d = a * a + b * b
u = (x * a + y * b) / d
v = (y * a - x * b) / d
x = xx
y = yy
a = aa
b = bb
lnz = x * x + y * y
u = 0
v = 0
mag
= EXP(a
* lnz
- b
* argz
) ang = a * argz + b * lnz
x = xx
y = yy
lnz = x * x + y * y
u = 0
v = 0
u = lnz
v = argz
cosh##
= 0.5##
* (EXP(x
) + EXP(-x
))
sinh##
= 0.5##
* (EXP(x
) - EXP(-x
))
x = xx
y = yy
x = xx
y = yy
rgamma
= SQR(2 * pi
* x
) * ((x
/ EXP(1)) ^ x
)
x = xx
y = yy
u = 1
v = 0
cexp uu, vv, x, y, x - 0.5, y
cexp p
, q
, EXP(1), 0, -x
, -y
cmul u, v, uu, vv, p, q
IF (x
> 1) THEN facto&
= x
* facto&
(x
- 1)