diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2020-03-20 01:57:25 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2020-03-20 01:57:25 +0000 |
commit | 2e832b23a4b84b4e11394aee406534a2e1d8cde1 (patch) | |
tree | e5380b47d172cc61f3b210058858ed767a5ad92b /editor | |
parent | dc1f1fa00674ea8f8ae24679bf1dde4f572b41a7 (diff) | |
download | netpbm-mirror-2e832b23a4b84b4e11394aee406534a2e1d8cde1.tar.gz netpbm-mirror-2e832b23a4b84b4e11394aee406534a2e1d8cde1.tar.xz netpbm-mirror-2e832b23a4b84b4e11394aee406534a2e1d8cde1.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3764 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r-- | editor/pamditherbw.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/editor/pamditherbw.c b/editor/pamditherbw.c index f4d9c4c2..ae91a26f 100644 --- a/editor/pamditherbw.c +++ b/editor/pamditherbw.c @@ -198,8 +198,10 @@ typedef struct { typedef struct { + bool firstPointDone; unsigned int order; unsigned int ord; + /* Meaningful only when 'firstPointDone' is true */ int turn; int dx; int dy; @@ -220,18 +222,19 @@ hilbert_init(Hilbert * const hilP, /*---------------------------------------------------------------------------- Initialize the Hilbert curve tracer -----------------------------------------------------------------------------*/ - unsigned int maxDim; + unsigned int const maxDim = MAX(width, height); - hilP->width = width; + unsigned int order; + + hilP->width = width; hilP->height = height; - maxDim = MAX(width, height); { unsigned int ber; - for (ber = 2, hilP->order = 1; ber < maxDim; ber <<= 1, ++hilP->order); + for (ber = 2, order = 0; ber < maxDim; ber <<= 1, ++order); } - assert(hilP->order <= ARRAY_SIZE(hilP->stage)); - hilP->ord = hilP->order; - --hilP->order; + assert(order + 1 <= ARRAY_SIZE(hilP->stage)); + hilP->order = order; + hilP->firstPointDone = false; } @@ -241,14 +244,14 @@ hilbert_doFirstPoint(Hilbert * const hilbertP, bool * const gotPointP, Point * const pointP) { - --hilbertP->ord; + hilbertP->ord = hilbertP->order; hilbertP->stage[hilbertP->ord] = 0; hilbertP->turn = -1; hilbertP->dy = 1; hilbertP->dx = hilbertP->x = hilbertP->y = 0; + hilbertP->firstPointDone = true; pointP->x = 0; pointP->y = 0; - *gotPointP = true; } @@ -382,7 +385,7 @@ hilbert_trace(Hilbert * const hilbertP, ... Return *gotPointP true iff we got another point -----------------------------------------------------------------------------*/ - if (hilbertP->ord > hilbertP->order) { + if (!hilbertP->firstPointDone) { hilbert_doFirstPoint(hilbertP, gotPointP, pointP); } else { hilbert_advanceStateMachine(hilbertP, gotPointP, pointP); |