home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / vifs / ifs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-14  |  2.7 KB  |  88 lines

  1. /*
  2.  *    IFS.h  -- iterated function system structures and constants.
  3.  *
  4.  *     4 june 1989  Olle Olsson
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include "egargb.h"
  9.  
  10. /* data file */
  11. #define COMMENTCH '#'        /* comment line start char */
  12.  
  13. /* plot size */
  14. #define MAX_COL    (max_x_coord)
  15. #define MAX_ROW    (max_y_coord)
  16.  
  17. /* ifsdes.density to iterations */
  18. #define DENS2ITER( d )    ((long) ((d) * (MAX_COL + 1L) * (MAX_ROW + 1L)))
  19.  
  20. /* iterations to ifsdes.density */
  21. #define ITER2DENS( it )    ((it) / ((MAX_COL + 1.0) * (MAX_ROW + 1.0)))
  22.  
  23. /* useful constants */
  24. #define MAXRAND 0x7fff        /* max value from rand() */
  25. #define MINPROB 1e-6        /* minimum probability */
  26.  
  27. typedef struct
  28.     {
  29.     double a11, a12;    /* one transformation matrix */
  30.     double a21, a22;
  31.     double b1, b2;        /* translation vector */
  32.     double prob;        /* probability */
  33.     int color;        /* color index */
  34.     int group;        /* transform group index */
  35.     } transform;
  36.  
  37. typedef struct            /* a rectangular area */
  38.     {
  39.     double xlow;        /* low x */
  40.     double xlen;
  41.     double ylow;        /* low y */
  42.     double ylen;
  43.     } area;
  44.  
  45. typedef struct            /* a description for showing the ifs */
  46.     {
  47.     transform *tp;        /* the transforms (vector) */
  48.     int size;        /* number of (active) transforms */
  49.     int maxsize;        /* size of the transform vector */
  50.     double density;        /* == iterations / screen_points */
  51.     double prrdens;        /* density from previous run */
  52.     area area;        /* limiting area */
  53.     rgb *colors;        /* colors (index 0 is backgr.) */
  54.     int clrsize;        /* max number of colors */
  55.     int textcolor;        /* color index for menus etc. */
  56.     int im;            /* flag/size for invariant measure mode */
  57.     int im_prev;        /* previous im size for on/off flip */
  58.     int maxgroup;        /* maximum group number (0 is minimum) */
  59.     } ifsdes;
  60.  
  61. /* globals */
  62. extern int grmode;            /* mode for setgraphmode() */
  63. extern int max_x_coord, max_y_coord;    /* screen max x & y */
  64.  
  65. /* the functions */
  66. void main( int argc, char *argv[] );
  67. void beep( void );
  68. void error( char *s, ... );
  69. void warning( char *s, ... );
  70. void usage( void );
  71. double dett( transform *tp );
  72. void rdescr( FILE *infile, ifsdes *dp, int show );
  73. void wdescr( FILE *outfile, ifsdes *dp, char *comment, int show );
  74.  
  75. void normprob( transform *tp, int size );
  76. double grprob( transform *tp, int size, int group );
  77. void normgprob( transform *tp, int size, int group, double group_prob );
  78.  
  79. void showtrans( transform *tp, int *probp, int size, area *ap );
  80. void ifsshow( ifsdes *dp, int (*stop)( void ), int earlystop,
  81.                 void (far *wpix)( int x, int y, int color ),
  82.                 unsigned (far *rpix)( int x, int y ) );
  83. void setuprgb( transform *tp, int size );
  84. int ifsrand( ifsdes *dp, int minsize, int maxsize, int show );
  85. int edtrans( ifsdes *dp, int trace );
  86. void palsetup( ifsdes *dp );
  87.  
  88.