I'm not sure if this is a major, major bug, or just a flaw in my code, but the 
following doesnt seem to draw anything.
#include <fltk/run.h>
#include <fltk/ask.h>
#include <fltk/draw.h>
#include <fltk/Window.h>
using namespace fltk;
class Dragon_Curve : Widget {
  int amount, size;
  void draw() {
    int dragon_x=w()/2,dragon_y=h()/2,dragon_oldx=w()/2,dragon_oldy=h()/2;
    char direction=0;
    setcolor(BLACK);
    for (int i=1;i<=amount;i++) {
      dragon_oldx = dragon_x;
      dragon_oldy = dragon_y;
      switch (direction) {
        case 0: dragon_y-=size;break;
        case 1: dragon_x-=size;break;
        case 2: dragon_y+=size;break;
        case 3: dragon_x+=size;break;
      }
      drawline(x()+dragon_oldx, y()+dragon_oldy,x()+dragon_x, y()+dragon_y);
      direction = (direction+dragon_turn(i))%4;
    }
  }
  char dragon_turn(unsigned int n) {
    return (((n & -n) << 1) & n) != 0;
  }
  public:
  Dragon_Curve(int x,int y,int w,int h,int amount_,int size_) : Widget 
(x,y,w,h) {
    amount = amount_;
    size = size_;
  }
  Dragon_Curve(int x,int y,int w,int h,char* l) : Widget (x,y,w,h,l) {
    amount = 15;
    size = 10;
  }
};

int main(int argc, char** argv) {
  Window w(700,600);
  Dragon_Curve dc(0,0,700,600,15,10);
  w.end();
  w.show(argc,argv);
  return run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to