From: ian Date: Sun, 3 Apr 2005 15:54:58 +0000 (+0000) Subject: sotextpit X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius.git;a=commitdiff_plain;h=423c7eda1487df41623921cb5b4b83030ee1006a sotextpit --- diff --git a/Makefile b/Makefile index f092b5b..54e8061 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CPPFLAGS= -I/usr/include \ - -Wall -O2 -Wmissing-prototypes -Wstrict-prototypes \ + -Wall -O2 -g -Wmissing-prototypes -Wstrict-prototypes \ -Wno-deprecated \ $(WERROR) WERROR=-Werror diff --git a/dualx11.cc b/dualx11.cc index 5c40ba2..6a2edd5 100644 --- a/dualx11.cc +++ b/dualx11.cc @@ -63,21 +63,36 @@ DualX11Output::~DualX11Output() { XCloseDisplay(display); } -void DualX11Output::drawcell(const Point* list, int n) { - static Parameter eyeseparation("eyesep", - "Distance from projection eye to origin", - 0.3, .1, 0., 100.); +void DualX11Output::drawcell(const Point* list, int n, Colour colour) { + static Parameter + eyeseparation("eyesep", "Distance from projection eye to origin", + 0.3, .1, 0., 100.); + for (int i=0; i<2; i++) { + GC fill; + bool draw; + Point::seteyex(eyeseparation*(i-0.5)); + + switch (colour) { + case grid: fill= fabric[i]; draw= true; break; + case solidblack: fill= fabric[i]; draw= false; break; + case solidwhite: fill= mesh[i]; draw= false; break; + default: abort(); + } + XPoint xp[n+1]; for (int j=0; j0 ? n : 1; } +static Parameter +sotextpit("sotextpit", "Pitch of solid texture (0: grid mode)", + 0., 1., 0., 1000.); + void Cell::display(Output& o) { int nn[4]; int totalnn= 0; @@ -30,14 +35,28 @@ void Cell::display(Output& o) { } Point *array= new Point[totalnn]; Point *inarrayp= array; + Point mean(0,0,0); for (i=0; i<4; i++) { for (int a=0; a 0) { + bool white= false; + for (i=0; i<3; i++) { + double intpartdummy; + double remainder= modf(mean[i] / sotextpit, &intpartdummy); + if (remainder >= 0.5 || (remainder >= -0.5 && remainder < 0.0)) + white= !white; + } + colour= white ? Output::solidwhite : Output::solidblack; } - o.drawcell(array,totalnn); + o.drawcell(array,totalnn,colour); delete[] array; } diff --git a/output.hh b/output.hh index 92cc33b..4b40747 100644 --- a/output.hh +++ b/output.hh @@ -9,7 +9,8 @@ struct Output { virtual ~Output(){}; - virtual void drawcell(const Point*, int) =0; + enum Colour { grid, solidblack, solidwhite }; + virtual void drawcell(const Point *list, int n, Colour colour) =0; virtual void startimage(){}; virtual void endimage(){}; }; diff --git a/postscript.cc b/postscript.cc index 3fbe4e7..f27a081 100644 --- a/postscript.cc +++ b/postscript.cc @@ -29,11 +29,23 @@ PostScriptOutput::~PostScriptOutput() { "%%EOF\n"; } -void PostScriptOutput::drawcell(const Point* list, int n) { - Onscreen p[4]; - for (int i=0; i<4; i++) p[i]= Onscreen(list[i]); - docell(p,n,"1 setgray fill"); - docell(p,n,"0 setgray stroke"); +void PostScriptOutput::drawcell(const Point* list, int n, Colour colour) { + Onscreen p[n]; + for (int i=0; i