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


An fast realtime interactive fractal zoomer

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

3.3 Filters

This is a brief description of filter system used internally by XaoS. Filters in XaoS provides an object oriented interface to every part of XaoS engine. Main filters are: User interface implemented in ui_helper.c and zooming engine implemented in zoom.c. Filters are connected into an queue - at the beggining there is just two filters here(zoom and ui) but later additional filters should be inserted into the middle of queue like an stereogram generation etc. The queue supports operations like remove filter, add filter and initialize.

In the caluclation every filter should use data caluclated by filter lower in the queue. Data are stored into image. So for example stereogram filter should use fractal generated by zooming engine and create an stereogram.

This makes XaoS's code more flexible and makes easy future enhancements like different zooming engine, image rotation, other special effects, plug-ins and some other funny stuff since interface of each such part is well defined and each filter has quite good control over his childs. So stereogram filter should change palette, force zooming engine to change depth, width and height of calchlated image to fit his needs and so on.

This document describes mainly creating of filter like stereogram generator i.e. filter placed into middle of queue since I don't expect there will be many people creating "terminal" filters (zooming engines/user interface layer) note that different user interface is possible since user interface layer is not the real user interface just set of high level functions that should be called by main application like set_view. So in case you want to use XaoS as an calculation engine in your program this document is probably not for you.

Each filter is defined by filter_action structures as follows:
 
struct filteraction {
  char *name;
  char *shortname;
  int flags;
  struct filter *(*getinstance)(struct filteraction *a);
  void (*destroyinstance)(struct filter *f);
  int (*doit)(struct filter *f,int flags,int time);
  int (*requirement)(struct filter *f,struct requirements *r);
  int (*initialize)(struct filter *f,struct initdata *i);
  void (*convertup)(struct filter *f,int *x,int *y);
  void (*convertdown)(struct filter *f,int *x,int *y);
  void (*removefilter)(struct filter *f);
};
This structure describes static filter's parameters (like its name) and basic set of methods required for communication with resto of XaoS. The name field describes filter's name like "An random dot stereogram generator". Name is displayed by ugly interface in filter's menu. So it is expected to be descrptive and shorter than 30 characters. The short name is one word long name for filter like "stereogram". This name is used by save files, possibly by command line parameters. Simply everywhere where user should need to write it and writing long descriptive name should be just wasting of time and disk space.

Flags field is kept for future enhancements and is expected to be 0 for now.


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

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