www.delorie.com/gnu/docs/xaos/xaos_36.html   search  
Buy GNU books!

An fast realtime interactive fractal zoomer

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.7 Dynamic Resolution

The above optimizations often do not help enough and image calculation is still too slow. One option was to reduce the framerate, but a framerate lower than 5 frames per second is unbearable. Another option is simply to calculate only the details that can be determined within a time interval.

Rows/columns not calculated are simple approximated by referencing the nearest other row/column. The result is an image with larger pixels. One problem is the fact that the order of calculating the rows/columns is significant. Previous versions of XaoS simply calculated all rows from top to bottom and then columns from left to right. Using the dynamic resolution code with this algorithm would result in distorted images. This was solved by adding priority to every row/column and calculating the high priority row/column first. The algorithm for adding these priorities is as follows:

This function produces quite good results. It tends to make same size rectangles on the whole image and does not depend on resolution.

Another interesting optimization is that during the zoom it is more advantageous to calculate rows/columns in the center of the zoom instead of the borders since these will be in the viewport longer and the user is usually focusing on center of the zoom anyhow.

This is done by simply adding to the calculated priority normal_priority / (abs(newposition - oldposition) / step + 1). This prefers rows/columns that do not move a great deal. Of course, unzooming uses the formula reversed.

The last variable to consider is the time interval for one frame. Setting it too low makes the calculation slow. Setting it too high makes the framerate too low. So the amount of time spent in other parts of the program is calculated and multiplied by 5 to determine the interval. If time is then lower than 15FPS, 15FPS is used instead, since slower animations are unacceptable. At the other hand if it is higher than 35FPS, it is set to 35FPS, since higher framerate is just wasting of computer resources. When image is not animating, this values is changed, so framerate is choosed between 5FPS and 15FPS. This caused that images are calcualted quickly after zooms stops.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003