Merge pull request #254 from xexyl/1994-tvr

Fixes in 1994/tvr/README.md
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-04-02 16:26:03 -07:00
commit ee5ab83ba5
1 file changed
+120 -124
+120 -124
View File
@@ -10,131 +10,133 @@
make all make all
## To run ## To run:
```sh
./tvr mode screensize/2 < colormapfile ./tvr mode screensize/2 < colormapfile
```
## Judges' comments ## Try:
Try: ```sh
./tvr 0 128 < tvr.color (for color displays) ./tvr 0 128 < tvr.color (for color displays)
./tvr 0 128 < tvr.bw (for Black & White displays) ./tvr 0 128 < tvr.bw (for Black & White displays)
```
Mode may be a value from 0 to 12. Mode may be a value from 0 to 12.
This entry requires the use of X11. It will form two windows ## Alternative code:
(hopefully your window mangler will ask you to place these
your display) which you should place side by side. Move the
cursor around in one of the two windows and watch what happens.
The fractally minded may be able to detect that mode 0 does not
calculate Mandelbrot/Julian sets correctly. Can you find the bug?
Better still, can you fix it without breaking something else?
The author has provided us a spoiler version: The author has provided us a spoiler version:
make tvr.alt make tvr.alt
./tvr.alt altmode screensize/2 < colormapfile ./tvr.alt altmode screensize/2 < colormapfile
where altmode 1-4 correspond to mode 0-3 in the original entry where `altmode` `1` - `4` correspond to mode `0` - `3` in the original entry and
and altmode 0 calculates Mandelbrot/Julian sets correctly. `altmode 0` calculates Mandelbrot/Julian sets correctly.
## Author's comments
Interactive Fractals for X Window System
This program contains 4 pairs of fractals/effects and 3 methods of ## Judges' comments:
animating them. There are two windows for a pair of fractals, one
of which contains static fractal (eg. Mandelbrot set) and the
other an animating one (eg. Julian set) which is derived from the
same formula as the static one. Only one pair of fractals can be
displayed on one process.
This entry requires the use of X11. It will form two windows (hopefully your
window manager will ask you where to place these in your display) which you
should place side by side. Move the cursor around in one of the two windows and
watch what happens.
The fractally minded may be able to detect that mode 0 does not calculate
Mandelbrot/Julian sets correctly. Can you find the bug? Better still, can you
fix it without breaking something else?
## Author's comments:
### Interactive Fractals for X Window System
This program contains four pairs of fractals/effects and three methods of
animating them. There are two windows for a pair of fractals, one of which
contains static fractal (e.g. Mandelbrot set) and the other an animating one
(e.g. Julian set) which is derived from the same formula as the static one. Only
one pair of fractals can be displayed in one process.
To animate the fractal, you must move your mouse on the static To animate the fractal, you must move your mouse on the static
fractal -window and the animated fractal will be calculated based fractal window and the animated fractal will be calculated based
on mouse coordinates. If you are on one of the two non-stable on mouse coordinates. If you are on one of the two non-stable
modes (more about them later) you can stabilize the picture by modes (more about them later) you can stabilize the picture by
pressing a mouse button. Pressing it does nothing on stable mode. pressing a mouse button. Pressing it does nothing on stable mode.
The three modes are: The three modes are:
- non-stable mode with simple 'attractor searcher' - non-stable mode with simple 'attractor searcher'
- non-stable mode - non-stable mode
- stable mode - stable mode
On Mandelbrot/Julian mode the stable mode calculates normal Julian On Mandelbrot/Julian mode the stable mode calculates normal Julian set according
set according to the Mandelbrot coordinates (mouse position). On to the Mandelbrot coordinates (mouse position). On non-stable modes the picture
non-stable modes the picture slowly transforms to the same picture slowly transforms to the same picture as on the stable mode but transformation
as on the stable mode but transformation can take some can take some time. Usually, and especially if changes are relatively small
time. Usually, and especially if changes are relatively small between mouse movements or frame rate is high, the non-stable mode makes much
between mouse movements or frame rate is high, the non-stable mode more interesting effects IMHO. The difference between the two non-stable modes
makes much more interesting effects IMHO. The difference between is that the first tries to stabilize the picture. It doesn't stabilize much, but
2 non-stable modes is that the first tries to stabilize it helps in some cases quite a lot. One notable case where help can be seen is
picture. It doesn't stabilize much, but it helps on some cases when you first move your mouse to non-black areas of the Mandelbrot set, then
quite a lot. One notable case where help can be seen is when you back to near the center. In some cases 'attractor searcher' can be seen as
first move your mouse to non-black areas of Mandelbrot set, then noise.
back to near the center. On some cases 'attractor searcher' can be
seen as noise.
First of the fractal pairs is Mandelbrot/Julianset as mentioned The first of the fractal pairs is Mandelbrot/Julian set as mentioned before. The
before. Second is a variation of that. Third makes nice second is a variation of that. The third makes nice 3d-look-a-like effects and
3d-look-a-like effects and fourth is variation of that with more the fourth is a variation of that with more nice effects.
nice effects.
Usage: ### Usage:
tvr mode screensize/2 < colormapfile
The first parameter is the operating-mode of the program. There ```sh
are 4 fractal pairs, 3 display modes, making total of 12 ./tvr mode screensize/2 < colormapfile
modes. Screensize is half of the actual screenlength/width. ie. If ```
you use 128 as a second parameter, you will get two 256x256
windows.
Program needs reasonable values for both of these parameters to
operate. Good first try could be "0 128" or "8 128". Colormap has The first parameter is the operating-mode of the program. There are 4 fractal
pairs, 3 display modes, making total of 12 modes. `Screensize` is half of the
actual `screenlength/width`. I.e. if you use 128 as a second parameter, you will
get two 256x256 windows.
The program needs reasonable values for both of these parameters to
operate. A good first try could be "0 128" or "8 128". `Colormap` has
to be piped into the programs standard input. to be piped into the programs standard input.
Note that you will need approximately (secondparameter^2)*64 bytes Note that you will need approximately `(second_parameter^2)*64` bytes of free
of free main memory or machine will swap heavily (memory main memory or the machine will swap heavily (memory references are quite random
references are quite random and may confuse paging algorithms and may confuse paging algorithms easily). This means that for 512x512 windows
easily). This means that for 512x512 windows you will need 4M of you will need 4M of memory.
memory.
Colormapfile: ### `Colormapfile`:
This is the file from which program reads colors for screen This is the file from which program reads colors for screen `colormap`. The
colormap. First line of the file must be a number between first line of the file must be a number between `3..254`. This informs the
3..254. This informs the program how many colors there are to be program how many colors there are to be expected. This is also the maximum
expected. This is also the maximum number of iterations used on number of iterations used on picture calculations. Lines after that are X11
picture calculations. Lines after that are X11 color color names. The program expects to find, and it uses, the number of colors
names. Program expects to find, and uses, the number of colors reported on the first line.
reported on first line.
There are 2 colormapfiles to start with. One with colors and There are two `colormapfiles` to start with. One with colors and another with
another with only black and white. If you have enough colors on only black and white. If you have enough colors on your display you can use the
your display you can use the one with colors (even on one with colors (even on `grayscale`). The other is meant mainly for a one bit
grayscale). The other is meant mainly for 1 bitplane display plane display (on which the picture looks terrible compared to a 8 bit plane
(on which the picture looks terrible compared to 8 bitplane
display). display).
Compilation: ### Compilation:
You should compile this entry with optimizing compiler with the
highest level of optimization possible. You will also need an ansi
compatible compiler (gcc -ansi -pedantic will do fine).
You should compile this entry with an optimizing compiler with the
highest level of optimization possible. You will also need an ANSI
compatible compiler (`gcc -ansi -pedantic` will do fine).
This entry has been tested on wide variety of machines including: This entry has been tested on wide variety of machines including:
```
Machine OS Machine OS
------- -- ------- --
Decstation 5000/240 Ultrix 4.3A Decstation 5000/240 Ultrix 4.3A
@@ -142,76 +144,70 @@
IBM RS6000 AIX v3 IBM RS6000 AIX v3
SPARCStation IPX SunOS 4.1.3 SPARCStation IPX SunOS 4.1.3
i486 Linux v1.1.8 (binarysize 3576 bytes i486 Linux v1.1.8 (binarysize 3576 bytes
using gcc -O6 -s -N ;) using `gcc -O6 -s -N` ;)
HP 9000/730 HP-UX HP 9000/730 HP-UX
```
Also, many of X-server and Xlibrary version have been tested and Also, many of the X server and X library versions have been tested and the
the program should be highly portable. Program may slow down program should be highly portable. The program may slow down considerably on
considerably on machines where table references are slow as the machines where table references are slow as the program makes extensive use of
program makes extensive use of them. Also, due to the huge amount them. Also, due to the huge amount of data sent to the X server, considerable
of data sent to the X-server, considerable slowdown can be noticed slowdown can be noticed if the X server is slow or especially if the connection
if the Xserver is slow or especially if the connection between the between the X server and the client is slow. (Don't try this on 9600 bps modem
Xserver and the client is slow. (Don't try this on 9600 bps modem line. I did ;) )
line. I did ;)
Obfuscation is done on different levels. Almost none of it is made Obfuscation is done on different levels. Almost none of it is made at the macro
at the macro level, so cpp:ing the code won't give you level, so `cpp`ing the code won't give you much. Perhaps most notable is the
much. Perhaps most notable is the algorithmic obfuscation. Simple algorithmic obfuscation. Simple formula has been turned into something
formula has been turned into something completely different. Also completely different. Also it may be a surprise to find out which piece of the
it may be a surprise to find out which piece of the code code calculates non-stable fractals and how it does that. Many obfuscations were
calculates non-stable fractals and how it does that. Many left out of the program because speed of animation was one of the key issues.
obfuscations were left out of the program because speed of Well, obfuscated or not, some of the effects are very nice ;)
animation was one of the key issues. Well, obfuscated or not,
some of the effects are very nice ;)
Memory refreshment: ### Memory refreshment:
Mandelbrot set is calculated from the formula
Mandelbrot set is calculated from formula
2 2
Z = Z + Z Z = Z + Z
n+1 n 0 n+1 n 0
and Julian set is calculated from formula
and the Julian set is calculated from the formula
2 2
Z = Z + C Z = Z + C
n+1 n n+1 n
where C is the same throughout the picture. Both
calculation are finished when |Z| >= 2.0. For the other
fractals, the basic methods are the same but formula is
different (look from the source ;)
Note that Mandelbrot and Julian on this program aren't where `C` is the same throughout the picture. Both calculation are finished
exactly correct. Find out why ;) when `|Z| >= 2.0`. For the other fractals, the basic methods are the same but
the formula is different (look at the source ;)
Note that Mandelbrot and Julian on this program aren't exactly correct. Find out
why ;)
Bugs: ### Bugs:
- No error checking. If DISPLAY is not set program dumps core. - No error checking. If DISPLAY is not set program dumps core. This may also
This may also happen if a request of some of the resources happen if a request of some of the resources fails e.g. getting colors.
fails. eg. getting colors. - No expose event handling.
- It may be possible that the program starts drawing before window is mapped as
- No expose event handling there is no XSync(). In that case drawn data is lost. Also, some window manager
configurations places the second window on top of the first and again drawn
- It may be possible that the program starts drawing before data will be lost. By default, windows are placed next to the other in the
window is mapped as there is no XSync(). In that case drawn top left corner of the screen.
data is lost. Also, some window manager configurations places - Zooming is not possible.
the second window on top of the first and and again drawn data - Eats LOTS of memory on BIG pictures. Also lots of CPU resources. Under mode
will be lost. By default, windows are placed next to the other 0, the boundary condition is not checked properly. The condition `|Z| >= 2.0`
in the topleft corner of the screen. should be checked exactly (by comparing `x*x+y*y` with `2*2`), or else artifacts
are introduced. The result of this error is a "bubbly" appearance (at least in
- Zooming is not possible mono).
- Eats LOTS of memory on BIG pictures. Also lot's of CPU.
- Under mode 0, the boundary condition is not checked properly.
The condition |Z| >= 2.0 should be checked exactly (by comparing
x*x+y*y with 2*2), or else artifacts are introduced. The result
of this error is a "bubbly" appearance (at least in mono).
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License: