home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
new
/
dev
/
obero
/
oberon
/
demos
/
mandelbrot.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1994-11-24
|
3KB
|
78 lines
Syntax10.Scn.Fnt
FoldElems
Syntax10.Scn.Fnt
VAR z, d: COMPLEX; i: INTEGER;
BEGIN i:=0; z:=c; d.re:=z.re*z.re; d.im:=z.im*z.im;
WHILE (i <= N) & (d.re+d.im <= 4.0) DO
z.im:=2*z.re*z.im+c.im; z.re:=d.re-d.im+c.re;
d.re:=z.re*z.re; d.im:=z.im*z.im;
INC(i)
END;
RETURN i
END Iterate;
Syntax10.Scn.Fnt
FoldElems
Syntax10.Scn.Fnt
z: COMPLEX; startre, stepre, stepim: REAL; x, yh, yl, ym: INTEGER; ch: CHAR; M: Viewers.ViewerMsg;
Syntax10i.Scn.Fnt
Syntax10.Scn.Fnt
startre:=-2.0; stepre:=2.0/Display.Width; stepim:=2.0/Display.Height; z.re:=startre; z.im:=1.0;
yh:=Display.Height; ym:=Display.Height DIV 2; yl:=-1;
Syntax10.Scn.Fnt
Display.ReplConst(Display.black, 0, 0, Display.Width, Display.Height, Display.replace);
Syntax10.Scn.Fnt
(yh > ym)
Syntax10.Scn.Fnt
(Input.Available()=0)
Syntax10.Scn.Fnt
FoldElems
Syntax10.Scn.Fnt
IF ODD(Iterate(z)) THEN
Display.Dot(Display.white, x, yh, Display.replace);
Display.Dot(Display.white, x, yl, Display.replace)
END;
INC(x); z.re:=z.re+stepre
Syntax10i.Scn.Fnt
DEC(yh); INC(yl);
z.im:=z.im-stepim; x:=0; z.re:=startre;
WHILE x < Display.Width DO
draw dot if odd number of iterations
Syntax10.Scn.Fnt
Input.Read(ch);
Syntax10.Scn.Fnt
M.id:=Viewers.suspend; Viewers.Broadcast(M); M.id:=Viewers.restore; Viewers.Broadcast(M)
(*Display.Height is always even under MacOberon 3.x *)
VAR
some variables
BEGIN
init variables
clear screen
WHILE
not all lines processed
no key pressed
process next line
END;
wait for key press
refresh screen
END Draw;
Syntax10i.Scn.Fnt
MODULE Mandelbrot; (* Michael Franz, 16.1.92 / 25.10.93 *)
IMPORT
Display, Input, Viewers;
CONST
N=50;
TYPE
COMPLEX=RECORD re, im: REAL END;
PROCEDURE Iterate(c: COMPLEX): INTEGER;
PROCEDURE Draw*;
click on the triangle to expand the folded text
END Mandelbrot.Draw <- This is a command that can be executed directly.
This document contains "hypertext folds" that aid in the construction
of programs via the process of stepwise refinement.
You can compile this program without first expanding all of the folded text
by marking this viewer (press Enter on the keypad) and using the command
XE.Comp *
In order to expand and collaps all of the folds simultaneously, mark this
viewer and execute one of the two commands below:
FoldElems.Expand FoldElems.Collapse