iterator.h File Reference

Various kinds of primitive OPC/animation/motion iteration. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LinePath
 3D linear motion in a can More...
struct  Animator
 Canned animation. More...

Defines

#define OPC_foreach(PIXEL, opc, pixel)
 Iterate each pixel of an opc; x is iterated left-to-right, y is iterated top-to-bottom.
#define OPC_foreach_mirror(PIXEL, opc, pixel)
 Iterate each pixel of an opc; x is iterated right-to-left, y is iterated top-to-bottom.
#define OPC_foreach_flip(PIXEL, opc, pixel)
 Iterate each pixel of an opc; x is iterated left-to-right y is iterated bottom-to-top.
#define OPC_foreach_mirror_flip(PIXEL, opc, pixel)
 Iterate each pixel of an opc, x is iterated right-to-left, y is iterated bottom-to-top.
#define OPC_translate_foreach(PIXEL, opcdst, opcsrc, pixel_dst, pixel_src)
 Iterate each pixel of two opcs (if differently sized, iterates smallest size); x is iterated left-to-right, y is iterated top-to-bottom.
#define IncLine(label)
 Fixed point Bresenham-like line calculator.
#define IncLine_Init_Step(ilabel, x1, y1, x2, y2)
 Initialize incremental line calculations to step point-by-point.
#define IncLine_Init_Span(ilabel, x1, y1, x2, y2)
 Initialize incremental line calculations to step span-by-span (uses lesser difference to make span).
#define IncLine_Init_Count(ilabel, x1, y1, x2, y2, nSamples)
 Initialize incremental line calculations to step over a count of steps.
#define IncLine_Step(ilabel)
 Step to next coordinate.
#define IncLine_nStep(ilabel, count)
 Step over next set of coordinates.
#define IncLine_Remains(ilabel)   ( ppConcat(ilabel,_remain) > 0 )
 Tell us if there are remaining steps.
#define IncLine_XY(ilabel, x, y)
 Get current X/Y from BresLine data.
#define IncLine_NextXY(ilabel, x, y)
 Get next X/Y from BresLine data without incrementing it.
#define IncLine_foreach(ilabel, iteratorx, iteratory)
 Iterate each point in IncLine.
#define IncLine_foreach_spans(ilabel, iteratorx, iteratory, iteratornx, iteratorny)
 Iterate each point in IncLine.
#define IncLine3D(label)
 Fixed point Bresenham-like line calculator.
#define IncLine3D_Init_Step(ilabel, x1, y1, x2, y2)
 Initialize incremental line calculations to step point-by-point.
#define IncLine3D_Init_Span(ilabel, x1, y1, x2, y2)
 Initialize incremental line calculations to step span-by-span (uses lesser difference to make span).
#define IncLine3D_Init_Count(ilabel, x1, y1, x2, y2, nSamples)
 Initialize incremental line calculations to step over a count of steps.
#define IncLine3D_Step(ilabel)
 Step to next coordinate.
#define IncLine3D_nStep(ilabel, count)
 Step over next set of coordinates.
#define IncLine3D_Remains(ilabel)   ( ppConcat(ilabel,_remain) > 0 )
 Tell us if there are remaining steps.
#define IncLine3D_XYZ(ilabel, x, y, z)
 Get current X/Y from BresLine data.
#define IncLine3D_NextXYZ(ilabel, x, y, z)
 Get next X/Y/Z from BresLine data without incrementing it.
#define IncLine3D_foreach(ilabel, iteratorx, iteratory, iteratorz)
 Iterate each point in IncLine3D.
#define IncLine3D_foreach_spans(ilabel, iteratorx, iteratory, iteratorz, iteratornx, iteratorny, iteratornz)
 Iterate each point in IncLine3D.

Enumerations

enum  Animator_Dir
 Simple animation types.

Functions

void LinePath_init (LinePath *self, int x1, int y1, int z1, unsigned msBegin, int x2, int y2, int z2, unsigned msFinish)
 Initialize linear motion.
void LinePath_setpos (LinePath *self, int x, int y, int z, unsigned msCurrent)
 Set current position in space, now.
void LinePath_moveto (LinePath *self, int x, int y, int z, unsigned msCurrent, unsigned msArrive)
 Move from current position to target.
bool LinePath_curr (const LinePath *self, int *x, int *y, int *z, unsigned msCurrent)
 Get current position in space, given time.
int Animator_init (Animator *self, int firstFrame, int lastFrame, Animator_Dir dir, unsigned msPerFrame)
 Initialize an animation.
int Animator_set (Animator *self, int frame)
 Set animation to single frame.
bool Animator_curr (Animator *self, int *frame, unsigned msCurrent)
 Get current animation frame.
bool Animator_pending (const Animator *self)
 Return true if we're pending a oneshot event.


Detailed Description

Various kinds of primitive OPC/animation/motion iteration.

Author:
David Mace

Definition in file iterator.h.


Define Documentation

#define IncLine ( label   ) 

Value:

int ppConcat(label,_x1);\
    int ppConcat(label,_y1);\
    int ppConcat(label,_x2);\
    int ppConcat(label,_y2);\
    int ppConcat(label,_x);\
    int ppConcat(label,_y);\
    int ppConcat(label,_dx);\
    int ppConcat(label,_dy);\
    int ppConcat(label,_remain);\
Fixed point Bresenham-like line calculator.

Parameters:
label Label to prepend to allow for multiple instances

Definition at line 113 of file iterator.h.

#define IncLine3D ( label   ) 

Value:

int ppConcat(label,_x1);\
    int ppConcat(label,_y1);\
    int ppConcat(label,_z1);\
    int ppConcat(label,_x2);\
    int ppConcat(label,_y2);\
    int ppConcat(label,_z2);\
    int ppConcat(label,_x);\
    int ppConcat(label,_y);\
    int ppConcat(label,_z);\
    int ppConcat(label,_dx);\
    int ppConcat(label,_dy);\
    int ppConcat(label,_dz);\
    int ppConcat(label,_remain);\
Fixed point Bresenham-like line calculator.

Parameters:
label Label to prepend to allow for multiple instances

Definition at line 307 of file iterator.h.

#define IncLine3D_foreach ( ilabel,
iteratorx,
iteratory,
iteratorz   ) 

Value:

int iteratorx = ppConcat(ilabel,_x1);\
    int iteratory = ppConcat(ilabel,_y1);\
    int iteratorz = ppConcat(ilabel,_z1);\
    for( ; ppConcat(ilabel,_remain)--; iteratorx = (ppConcat(ilabel,_x) += ppConcat(ilabel,_dx))>>16, iteratory = (ppConcat(ilabel,_y) += ppConcat(ilabel,_dy))>>16, iteratorz = (ppConcat(ilabel,_z) += ppConcat(ilabel,_dz))>>16 )
Iterate each point in IncLine3D.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
iteratorx What to call the x iterator
iteratory What to call the y iterator
iteratorz What to call the z iterator

Definition at line 506 of file iterator.h.

#define IncLine3D_foreach_spans ( ilabel,
iteratorx,
iteratory,
iteratorz,
iteratornx,
iteratorny,
iteratornz   ) 

Value:

int iteratorx = ppConcat(ilabel,_x1);\
    int iteratory = ppConcat(ilabel,_y1);\
    int iteratorz = ppConcat(ilabel,_z1);\
    int iteratornx, iteratorny, iteratornz;\
    IncLine3D_Step(ilabel);\
    IncLine3D_XYZ(ilabel, iteratornx, iteratorny,  iteratornz );\
    for( ; ppConcat(ilabel,_remain)--; iteratorx = iteratornx, iteratory = iteratorny, iteratorz = iteratornz, \
        iteratornx = (ppConcat(ilabel,_x) += ppConcat(ilabel,_dx))>>16, \
        iteratorny = (ppConcat(ilabel,_y) += ppConcat(ilabel,_dy))>>16, \
        iteratornz = (ppConcat(ilabel,_z) += ppConcat(ilabel,_dz))>>16 )
Iterate each point in IncLine3D.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
iteratorx What to call the x iterator
iteratory What to call the y iterator
iteratorz What to call the z iterator
iteratornx What to call the iterator for the 'next' x coordinate
iteratorny What to call the iterator for the 'next' y coordinate
iteratornz What to call the iterator for the 'next' z coordinate

Definition at line 522 of file iterator.h.

#define IncLine3D_Init_Count ( ilabel,
x1,
y1,
x2,
y2,
nSamples   ) 

Value:

{\
    ppConcat(ilabel,_x1) = (x1);\
    ppConcat(ilabel,_y1) = (y1);\
    ppConcat(ilabel,_z1) = (z1);\
    ppConcat(ilabel,_x2) = (x2);\
    ppConcat(ilabel,_y2) = (y2);\
    ppConcat(ilabel,_z2) = (z2);\
    ppConcat(ilabel,_x) = ppConcat(ilabel,_x1)<<16;\
    ppConcat(ilabel,_y) = ppConcat(ilabel,_y1)<<16;\
    ppConcat(ilabel,_z) = ppConcat(ilabel,_z1)<<16;\
    ppConcat(ilabel,_dx) = ppConcat(ilabel,_x2) - ppConcat(ilabel,_x1);\
    ppConcat(ilabel,_dy) = ppConcat(ilabel,_y2) - ppConcat(ilabel,_y1);\
    ppConcat(ilabel,_dz) = ppConcat(ilabel,_z2) - ppConcat(ilabel,_z1);\
    ppConcat(ilabel,_dx) = further(ppConcat(ilabel,_dx),1);\
    ppConcat(ilabel,_dy) = further(ppConcat(ilabel,_dy),1);\
    ppConcat(ilabel,_dz) = further(ppConcat(ilabel,_dz),1);\
    ppConcat(ilabel,_remain) = (nSamples);\
    ppConcat(ilabel,_dx) = (ppConcat(ilabel,_dx)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dy) = (ppConcat(ilabel,_dy)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dz) = (ppConcat(ilabel,_dz)<<16)/ppConcat(ilabel,_remain);\
}
Initialize incremental line calculations to step over a count of steps.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
x1,y1 First point in line
x2,y2 Last point in line (inclusive)
nSamples Number of steps we would prefer this to take, typically representing time samples for a path

Definition at line 393 of file iterator.h.

#define IncLine3D_Init_Span ( ilabel,
x1,
y1,
x2,
y2   ) 

Value:

{\
    ppConcat(ilabel,_x1) = (x1);\
    ppConcat(ilabel,_y1) = (y1);\
    ppConcat(ilabel,_z1) = (z1);\
    ppConcat(ilabel,_x2) = (x2);\
    ppConcat(ilabel,_y2) = (y2);\
    ppConcat(ilabel,_z2) = (z2);\
    ppConcat(ilabel,_x) = ppConcat(ilabel,_x1)<<16;\
    ppConcat(ilabel,_y) = ppConcat(ilabel,_y1)<<16;\
    ppConcat(ilabel,_z) = ppConcat(ilabel,_z1)<<16;\
    ppConcat(ilabel,_dx) = ppConcat(ilabel,_x2) - ppConcat(ilabel,_x1);\
    ppConcat(ilabel,_dy) = ppConcat(ilabel,_y2) - ppConcat(ilabel,_y1);\
    ppConcat(ilabel,_dz) = ppConcat(ilabel,_z2) - ppConcat(ilabel,_z1);\
    ppConcat(ilabel,_dx) = further(ppConcat(ilabel,_dx),1);\
    ppConcat(ilabel,_dy) = further(ppConcat(ilabel,_dy),1);\
    ppConcat(ilabel,_dz) = further(ppConcat(ilabel,_dz),1);\
    ppConcat(ilabel,_remain) = min(abs(ppConcat(ilabel,_dx)),abs(ppConcat(ilabel,_dy)));\
    ppConcat(ilabel,_remain) = min(ppConcat(ilabel,_remain),abs(ppConcat(ilabel,_dz)));\
    ppConcat(ilabel,_dx) = (ppConcat(ilabel,_dx)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dy) = (ppConcat(ilabel,_dy)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dz) = (ppConcat(ilabel,_dz)<<16)/ppConcat(ilabel,_remain);\
}
Initialize incremental line calculations to step span-by-span (uses lesser difference to make span).

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
x1,y1 First point in line
x2,y2 Last point in line (inclusive)

Definition at line 359 of file iterator.h.

#define IncLine3D_Init_Step ( ilabel,
x1,
y1,
x2,
y2   ) 

Value:

{\
    ppConcat(ilabel,_x1) = (x1);\
    ppConcat(ilabel,_y1) = (y1);\
    ppConcat(ilabel,_z1) = (z1);\
    ppConcat(ilabel,_x2) = (x2);\
    ppConcat(ilabel,_y2) = (y2);\
    ppConcat(ilabel,_z2) = (z2);\
    ppConcat(ilabel,_x) = ppConcat(ilabel,_x1)<<16;\
    ppConcat(ilabel,_y) = ppConcat(ilabel,_y1)<<16;\
    ppConcat(ilabel,_z) = ppConcat(ilabel,_z1)<<16;\
    ppConcat(ilabel,_dx) = ppConcat(ilabel,_x2) - ppConcat(ilabel,_x1);\
    ppConcat(ilabel,_dy) = ppConcat(ilabel,_y2) - ppConcat(ilabel,_y1);\
    ppConcat(ilabel,_dz) = ppConcat(ilabel,_z2) - ppConcat(ilabel,_z1);\
    ppConcat(ilabel,_dx) = further(ppConcat(ilabel,_dx),1);\
    ppConcat(ilabel,_dy) = further(ppConcat(ilabel,_dy),1);\
    ppConcat(ilabel,_dz) = further(ppConcat(ilabel,_dz),1);\
    ppConcat(ilabel,_remain) = max(abs(ppConcat(ilabel,_dx)),abs(ppConcat(ilabel,_dy)));\
    ppConcat(ilabel,_remain) = max(ppConcat(ilabel,_remain),abs(ppConcat(ilabel,_dz)));\
    ppConcat(ilabel,_dx) = (ppConcat(ilabel,_dx)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dy) = (ppConcat(ilabel,_dy)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dz) = (ppConcat(ilabel,_dz)<<16)/ppConcat(ilabel,_remain);\
}
Initialize incremental line calculations to step point-by-point.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
x1,y1 First point in line
x2,y2 Last point in line (inclusive)

Definition at line 329 of file iterator.h.

#define IncLine3D_NextXYZ ( ilabel,
x,
y,
 ) 

Value:

{\
    if( ppConcat(ilabel,_remain) )\
    {\
        (x) = (ppConcat(ilabel,_x)+ppConcat(ilabel,_dx))>>16;\
        (y) = (ppConcat(ilabel,_y)+ppConcat(ilabel,_dy))>>16;\
        (z) = (ppConcat(ilabel,_z)+ppConcat(ilabel,_dz))>>16;\
    }\
    else\
    {\
        (x) = ppConcat(ilabel,_x2);\
        (y) = ppConcat(ilabel,_y2);\
        (z) = ppConcat(ilabel,_z2);\
    }\
}
Get next X/Y/Z from BresLine data without incrementing it.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
x Int to receive X coordinate
y Int to receive Y coordinate
z Int to receive Z coordinate

Definition at line 483 of file iterator.h.

#define IncLine3D_nStep ( ilabel,
count   ) 

Value:

{\
    int nSkip = (count);\
    if( nSkip >= ppConcat(ilabel,_remain) )\
    {\
        ppConcat(ilabel,_x) = ppConcat(ilabel,_x2)<<16;\
        ppConcat(ilabel,_y) = ppConcat(ilabel,_y2)<<16;\
        ppConcat(ilabel,_z) = ppConcat(ilabel,_z2)<<16;\
    } \
    else \
    {\
        ppConcat(ilabel,_x) += ppConcat(ilabel,_dx) * nSkip;\
        ppConcat(ilabel,_y) += ppConcat(ilabel,_dy) * nSkip;\
        ppConcat(ilabel,_z) += ppConcat(ilabel,_dz) * nSkip;\
        ppConcat(ilabel,_remain) -= nSkip;\
    }\
}
Step over next set of coordinates.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
count Count of steps to skip over Useful for situations such as line clipping, where we know a certain number of segments or pixels will not be rendered

Definition at line 437 of file iterator.h.

#define IncLine3D_Remains ( ilabel   )     ( ppConcat(ilabel,_remain) > 0 )

Tell us if there are remaining steps.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
Returns:
true if there are remaining steps, false if there aren't

Definition at line 460 of file iterator.h.

#define IncLine3D_Step ( ilabel   ) 

Value:

{\
    if( ppConcat(ilabel,_remain) > 0 )\
    {\
        ppConcat(ilabel,_x) += ppConcat(ilabel,_dx);\
        ppConcat(ilabel,_y) += ppConcat(ilabel,_dy);\
        ppConcat(ilabel,_z) += ppConcat(ilabel,_dz);\
        ppConcat(ilabel,_remain)--;\
    }\
}
Step to next coordinate.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')

Definition at line 420 of file iterator.h.

#define IncLine3D_XYZ ( ilabel,
x,
y,
 ) 

Value:

{\
    (x) = ppConcat(ilabel,_x)>>16;\
    (y) = ppConcat(ilabel,_y)>>16;\
    (z) = ppConcat(ilabel,_z)>>16;\
}
Get current X/Y from BresLine data.

Parameters:
ilabel Describes label from IncLine3D with any instance indirection attached to it (i.e. 'mydata->label')
x Int to receive X coordinate
y Int to receive Y coordinate
z Int to receive Z coordinate

Definition at line 469 of file iterator.h.

#define IncLine_foreach ( ilabel,
iteratorx,
iteratory   ) 

Value:

int iteratorx = ppConcat(ilabel,_x1);\
    int iteratory = ppConcat(ilabel,_y1);\
    for( ; ppConcat(ilabel,_remain)--; iteratorx = (ppConcat(ilabel,_x) += ppConcat(ilabel,_dx))>>16, iteratory = (ppConcat(ilabel,_y) += ppConcat(ilabel,_dy))>>16 )
Iterate each point in IncLine.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
iteratorx What to call the x iterator
iteratory What to call the y iterator

Definition at line 278 of file iterator.h.

#define IncLine_foreach_spans ( ilabel,
iteratorx,
iteratory,
iteratornx,
iteratorny   ) 

Value:

int iteratorx = ppConcat(ilabel,_x1);\
    int iteratory = ppConcat(ilabel,_y1);\
    int iteratornx, iteratorny;\
    IncLine_Step(ilabel);\
    IncLine_XY(ilabel, iteratornx, iteratorny);\
    for( ; ppConcat(ilabel,_remain)--; iteratorx = iteratornx, iteratory = iteratorny, \
        iteratornx = (ppConcat(ilabel,_x) += ppConcat(ilabel,_dx))>>16, \
        iteratorny = (ppConcat(ilabel,_y) += ppConcat(ilabel,_dy))>>16 )
Iterate each point in IncLine.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
iteratorx What to call the x iterator
iteratory What to call the y iterator
iteratornx What to call the iterator for the 'next' x coordinate
iteratorny What to call the iterator for the 'next' y coordinate

Definition at line 291 of file iterator.h.

#define IncLine_Init_Count ( ilabel,
x1,
y1,
x2,
y2,
nSamples   ) 

Value:

{\
    ppConcat(ilabel,_x1) = (x1);\
    ppConcat(ilabel,_y1) = (y1);\
    ppConcat(ilabel,_x2) = (x2);\
    ppConcat(ilabel,_y2) = (y2);\
    ppConcat(ilabel,_y) = ppConcat(ilabel,_y1)<<16;\
    ppConcat(ilabel,_x) = ppConcat(ilabel,_x1)<<16;\
    ppConcat(ilabel,_dx) = ppConcat(ilabel,_x2) - ppConcat(ilabel,_x1);\
    ppConcat(ilabel,_dy) = ppConcat(ilabel,_y2) - ppConcat(ilabel,_y1);\
    ppConcat(ilabel,_dx) = further(ppConcat(ilabel,_dx),1);\
    ppConcat(ilabel,_dy) = further(ppConcat(ilabel,_dy),1);\
    ppConcat(ilabel,_remain) = (nSamples);\
    ppConcat(ilabel,_dx) = (ppConcat(ilabel,_dx)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dy) = (ppConcat(ilabel,_dy)<<16)/ppConcat(ilabel,_remain);\
}
Initialize incremental line calculations to step over a count of steps.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
x1,y1 First point in line
x2,y2 Last point in line (inclusive)
nSamples Number of steps we would prefer this to take, typically representing time samples for a path

Definition at line 180 of file iterator.h.

#define IncLine_Init_Span ( ilabel,
x1,
y1,
x2,
y2   ) 

Value:

{\
    ppConcat(ilabel,_x1) = (x1);\
    ppConcat(ilabel,_y1) = (y1);\
    ppConcat(ilabel,_x2) = (x2);\
    ppConcat(ilabel,_y2) = (y2);\
    ppConcat(ilabel,_y) = ppConcat(ilabel,_y1)<<16;\
    ppConcat(ilabel,_x) = ppConcat(ilabel,_x1)<<16;\
    ppConcat(ilabel,_dx) = ppConcat(ilabel,_x2) - ppConcat(ilabel,_x1);\
    ppConcat(ilabel,_dy) = ppConcat(ilabel,_y2) - ppConcat(ilabel,_y1);\
    ppConcat(ilabel,_dx) = further(ppConcat(ilabel,_dx),1);\
    ppConcat(ilabel,_dy) = further(ppConcat(ilabel,_dy),1);\
    ppConcat(ilabel,_remain) = min(abs(ppConcat(ilabel,_dx)),abs(ppConcat(ilabel,_dy)));\
    ppConcat(ilabel,_dx) = (ppConcat(ilabel,_dx)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dy) = (ppConcat(ilabel,_dy)<<16)/ppConcat(ilabel,_remain);\
}
Initialize incremental line calculations to step span-by-span (uses lesser difference to make span).

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
x1,y1 First point in line
x2,y2 Last point in line (inclusive)

Definition at line 154 of file iterator.h.

#define IncLine_Init_Step ( ilabel,
x1,
y1,
x2,
y2   ) 

Value:

{\
    ppConcat(ilabel,_x1) = (x1);\
    ppConcat(ilabel,_y1) = (y1);\
    ppConcat(ilabel,_x2) = (x2);\
    ppConcat(ilabel,_y2) = (y2);\
    ppConcat(ilabel,_y) = ppConcat(ilabel,_y1)<<16;\
    ppConcat(ilabel,_x) = ppConcat(ilabel,_x1)<<16;\
    ppConcat(ilabel,_dx) = ppConcat(ilabel,_x2) - ppConcat(ilabel,_x1);\
    ppConcat(ilabel,_dy) = ppConcat(ilabel,_y2) - ppConcat(ilabel,_y1);\
    ppConcat(ilabel,_dx) = further(ppConcat(ilabel,_dx),1);\
    ppConcat(ilabel,_dy) = further(ppConcat(ilabel,_dy),1);\
    ppConcat(ilabel,_remain) = max(abs(ppConcat(ilabel,_dx)),abs(ppConcat(ilabel,_dy)));\
    ppConcat(ilabel,_dx) = (ppConcat(ilabel,_dx)<<16)/ppConcat(ilabel,_remain);\
    ppConcat(ilabel,_dy) = (ppConcat(ilabel,_dy)<<16)/ppConcat(ilabel,_remain);\
}
Initialize incremental line calculations to step point-by-point.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
x1,y1 First point in line
x2,y2 Last point in line (inclusive)

Definition at line 131 of file iterator.h.

#define IncLine_NextXY ( ilabel,
x,
 ) 

Value:

{\
    if( ppConcat(ilabel,_remain) )\
    {\
        (x) = (ppConcat(ilabel,_x)+ppConcat(ilabel,_dx))>>16;\
        (y) = (ppConcat(ilabel,_y)+ppConcat(ilabel,_dy))>>16;\
    }\
    else\
    {\
        (x) = ppConcat(ilabel,_x2);\
        (y) = ppConcat(ilabel,_y2);\
    }\
}
Get next X/Y from BresLine data without incrementing it.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
x Int to receive X coordinate
y Int to receive Y coordinate

Definition at line 258 of file iterator.h.

#define IncLine_nStep ( ilabel,
count   ) 

Value:

{\
    int nSkip = (count);\
    if( nSkip >= ppConcat(ilabel,_remain) )\
    {\
        ppConcat(ilabel,_x) = ppConcat(ilabel,_x2)<<16;\
        ppConcat(ilabel,_y) = ppConcat(ilabel,_y2)<<16;\
    } \
    else \
    {\
        ppConcat(ilabel,_x) += ppConcat(ilabel,_dx) * nSkip;\
        ppConcat(ilabel,_y) += ppConcat(ilabel,_dy) * nSkip;\
        ppConcat(ilabel,_remain) -= nSkip;\
    }\
}
Step over next set of coordinates.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
count Count of steps to skip over Useful for situations such as line clipping, where we know a certain number of segments or pixels will not be rendered

Definition at line 217 of file iterator.h.

#define IncLine_Remains ( ilabel   )     ( ppConcat(ilabel,_remain) > 0 )

Tell us if there are remaining steps.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
Returns:
true if there are remaining steps, false if there aren't

Definition at line 238 of file iterator.h.

#define IncLine_Step ( ilabel   ) 

Value:

{\
    if( ppConcat(ilabel,_remain) > 0 )\
    {\
        ppConcat(ilabel,_x) += ppConcat(ilabel,_dx);\
        ppConcat(ilabel,_y) += ppConcat(ilabel,_dy);\
        ppConcat(ilabel,_remain)--;\
    }\
}
Step to next coordinate.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')

Definition at line 201 of file iterator.h.

#define IncLine_XY ( ilabel,
x,
 ) 

Value:

{\
    (x) = ppConcat(ilabel,_x)>>16;\
    (y) = ppConcat(ilabel,_y)>>16;\
}
Get current X/Y from BresLine data.

Parameters:
ilabel Describes label from IncLine with any instance indirection attached to it (i.e. 'mydata->label')
x Int to receive X coordinate
y Int to receive Y coordinate

Definition at line 246 of file iterator.h.

#define OPC_foreach ( PIXEL,
opc,
pixel   ) 

Value:

uint8* pixel##_edge = (uint8*)OPC_NAMING(Ptr)( (opc), (opc)->clip.left, (opc)->clip.top );\
    int pixel##_wide = RectWide((opc)->clip);\
    int pixel##_high = RectHigh((opc)->clip);\
    int pixel##_y,pixel##_x;\
    PIXEL* pixel;\
    for( pixel##_y = 0; pixel##_y < pixel##_high; ++pixel##_y, pixel##_edge += (opc)->pitch )\
    for( pixel##_x = 0, pixel = (PIXEL*)pixel##_edge; pixel##_x < pixel##_wide; ++pixel##_x, ++pixel )
Iterate each pixel of an opc; x is iterated left-to-right, y is iterated top-to-bottom.

Parameters:
PIXEL Type of pixels in OPC
opc OPC pointer to iterate pixels within
pixel What to name the pixel iterator You also get a 'pixel'_x and 'pixel'_y that mirror the coordinates being iterated, so if you named 'pixel' clyde, you'd have clyde_x and clyde_y

Definition at line 24 of file iterator.h.

#define OPC_foreach_flip ( PIXEL,
opc,
pixel   ) 

Value:

uint8* pixel##_edge = (uint8*)OPC_NAMING(Ptr)( (opc), (opc)->clip.left, (opc)->clip.bottom-1 );\
    int pixel##_wide = RectWide((opc)->clip);\
    int pixel##_y,pixel##_x;\
    PIXEL* pixel;\
    for( pixel##_y = RectHigh((opc)->clip); pixel##_y--; pixel##_edge -= (opc)->pitch )\
    for( pixel##_x = 0, pixel = (PIXEL*)pixel##_edge; pixel##_x < pixel##_wide; ++pixel##_x, ++pixel )
Iterate each pixel of an opc; x is iterated left-to-right y is iterated bottom-to-top.

Parameters:
PIXEL Type of pixels in OPC
opc OPC pointer to iterate pixels within
pixel What to name the pixel iterator You also get a 'pixel'_x and 'pixel'_y that mirror the coordinates being iterated, so if you named 'pixel' clyde, you'd have clyde_x and clyde_y

Definition at line 56 of file iterator.h.

#define OPC_foreach_mirror ( PIXEL,
opc,
pixel   ) 

Value:

uint8* pixel##_edge = (uint8*)OPC_NAMING(Ptr)( (opc), (opc)->clip.right-1, (opc)->clip.top );\
    int pixel##_wide = RectWide((opc)->clip);\
    int pixel##_high = RectHigh((opc)->clip);\
    int pixel##_y,pixel##_x;\
    PIXEL* pixel;\
    for( pixel##_y = 0; pixel##_y < pixel##_high; ++pixel##_y, pixel##_edge += (opc)->pitch )\
    for( pixel##_x = pixel##_wide, pixel = (PIXEL*)pixel##_edge; pixel##_x--; --pixel )
Iterate each pixel of an opc; x is iterated right-to-left, y is iterated top-to-bottom.

Parameters:
PIXEL Type of pixels in OPC
opc OPC pointer to iterate pixels within
pixel What to name the pixel iterator You also get a 'pixel'_x and 'pixel'_y that mirror the coordinates being iterated, so if you named 'pixel' clyde, you'd have clyde_x and clyde_y

Definition at line 40 of file iterator.h.

#define OPC_foreach_mirror_flip ( PIXEL,
opc,
pixel   ) 

Value:

uint8* pixel##_edge = (uint8*)OPC_NAMING(Ptr)( (opc), (opc)->clip.right-1, (opc)->clip.bottom-1 );\
    int pixel##_y,pixel##_x;\
    PIXEL* pixel;\
    for( pixel##_y = RectWide((opc)->clip); pixel##_y--; pixel##_edge -= (opc)->pitch )\
    for( pixel##_x = RectHigh((opc)->clip), pixel = (PIXEL*)pixel##_edge; pixel##_x--; --pixel )
Iterate each pixel of an opc, x is iterated right-to-left, y is iterated bottom-to-top.

Parameters:
PIXEL Type of pixels in OPC
opc OPC pointer to iterate pixels within
pixel What to name the pixel iterator You also get a 'pixel'_x and 'pixel'_y that mirror the coordinates being iterated, so if you named 'pixel' clyde, you'd have clyde_x and clyde_y

Definition at line 71 of file iterator.h.

#define OPC_translate_foreach ( PIXEL,
opcdst,
opcsrc,
pixel_dst,
pixel_src   ) 

Value:

const uint8* edge_src = (uint8*)OPC_NAMING(Ptr)( (opcsrc), (opcsrc)->clip.left, (opcsrc)->clip.top );\
    uint8* edge_dst = (uint8*)OPC_NAMING(Ptr)( (opcdst), (opcdst)->clip.left, (opcdst)->clip.top );\
    int pixel_wide = min( RectWide((opcsrc)->clip), RectWide((opcdst)->clip) );\
    int pixel_high = min( RectHigh((opcsrc)->clip), RectHigh((opcdst)->clip) );\
    int pixel_y,pixel_x;\
    const PIXEL* pixel_src;\
    PIXEL* pixel_dst;\
    for( pixel_y = 0; pixel_y < pixel_high; ++pixel_y, edge_src += (opcsrc)->pitch, edge_dst += (opcdst)->pitch )\
    for( pixel_x = 0, pixel_dst = (PIXEL*)edge_dst, pixel_src = (const PIXEL*)edge_src; pixel_x < pixel_wide; ++pixel_x, ++pixel_dst, ++pixel_src )
Iterate each pixel of two opcs (if differently sized, iterates smallest size); x is iterated left-to-right, y is iterated top-to-bottom.

Parameters:
PIXEL Type of pixels in OPC
opcdst Target OPC pointer to iterate pixels within
opcsrc Source OPC pointer to iterate pixels within
pixel_dst What to name the pixel iterator for destination
pixel_src What to name the pixel iterator for source You also get a pixel_x and pixel_y that mirror the coordinates being iterated Useful for two OPCs that need to be translated, but may be of different sizes

Definition at line 88 of file iterator.h.


Function Documentation

bool Animator_curr ( Animator self,
int *  frame,
unsigned  msCurrent 
)

Get current animation frame.

Parameters:
self Animation we're cycling
frame Int to receive frame index
msCurrent Realtime in milliseconds
Returns:
true if Animating, false if 'finished'

Definition at line 168 of file iterator.c.

00169 {
00170     if( msCurrent - self->msprev > self->msframe )
00171     {
00172         if( !self->msprev )
00173         {
00174             self->msprev = msCurrent;
00175             *frame = self->iFrame;
00176             return false;
00177         }
00178         self->msprev = msCurrent;
00179         switch( self->aDir )
00180         {
00181         case an_Stop:
00182             break;
00183         case an_ForwardOneshot:
00184             if( ++self->iFrame > self->lastFrame )
00185             {
00186                 *frame = self->iFrame = self->lastFrame;
00187                 self->aDir = an_Stop;
00188                 return false;
00189             }
00190             break;
00191         case an_BackwardOneshot:
00192             if( --self->iFrame < self->firstFrame )
00193             {
00194                 *frame = self->iFrame = self->firstFrame;
00195                 self->aDir = an_Stop;
00196                 return false;
00197             }
00198             break;
00199         case an_ForwardLoop:
00200             if( ++self->iFrame > self->lastFrame )
00201                 self->iFrame = self->firstFrame;
00202             break;
00203         case an_BackwardLoop:
00204             if( --self->iFrame < self->firstFrame )
00205                 self->iFrame = self->lastFrame;
00206             break;
00207         case an_ForwardPingPong:
00208             if( ++self->iFrame > self->lastFrame )
00209             {
00210                 self->iFrame = self->lastFrame-1;
00211                 self->aDir = an_BackwardPingPong;
00212             }
00213             break;
00214         case an_BackwardPingPong:
00215             if( --self->iFrame < self->firstFrame )
00216             {
00217                 self->iFrame = self->firstFrame + 1;
00218                 self->aDir = an_ForwardPingPong;
00219             }
00220             break;
00221         case an_Random:
00222             self->iFrame = self->firstFrame + (rand() % (1+self->lastFrame-self->firstFrame));
00223             break;
00224         }
00225 
00226     }
00227     *frame = self->iFrame;
00228     return true;
00229 }

int Animator_init ( Animator self,
int  firstFrame,
int  lastFrame,
Animator_Dir  dir,
unsigned  msPerFrame 
)

Initialize an animation.

Parameters:
self Animation we're cycling
firstFrame First frame index in set we're animating
lastFrame Last frame index in set we're animating
dir Animation type to apply
msPerFrame How many milliseconds each frame should be displayed
Returns:
true if Animating, false if 'finished'

Definition at line 106 of file iterator.c.

00107 {
00108     self->msprev = 0;
00109     self->msframe = msPerFrame;
00110     self->firstFrame = firstFrame;
00111     self->lastFrame = lastFrame;
00112     self->aDir = dir;
00113     switch( dir )
00114     {
00115         case an_Stop:
00116         case an_ForwardOneshot:
00117         case an_ForwardLoop:
00118         case an_ForwardPingPong:
00119         case an_Random:
00120             self->iFrame = firstFrame;
00121             break;
00122         case an_BackwardOneshot:
00123         case an_BackwardLoop:
00124         case an_BackwardPingPong:
00125             self->iFrame = lastFrame;
00126             break;
00127     }
00128     return firstFrame;
00129 }

bool Animator_pending ( const Animator self  ) 

Return true if we're pending a oneshot event.

Parameters:
self Animation we're cycling

Definition at line 151 of file iterator.c.

00152 {
00153     if( self->aDir == an_ForwardOneshot )
00154         return self->iFrame <= self->lastFrame;
00155     else if( self->aDir == an_BackwardOneshot )
00156         return self->iFrame >= self->firstFrame;
00157     return false;
00158 }

int Animator_set ( Animator self,
int  frame 
)

Set animation to single frame.

Parameters:
self Animation we're cycling
frame Frame to set

Definition at line 136 of file iterator.c.

00137 {
00138     self->msprev = 0;
00139     self->msframe = 0;
00140     self->aDir = an_Stop;
00141     self->firstFrame = frame;
00142     self->lastFrame = frame;
00143     self->iFrame = frame;
00144     return frame;
00145 }

bool LinePath_curr ( const LinePath self,
int *  x,
int *  y,
int *  z,
unsigned  msCurrent 
)

Get current position in space, given time.

Parameters:
self Motion we're operating
x,y,z A place to put current position
msCurrent Current time
Returns:
true if moving or motion pending, false if 'finished' (after msFinish from LinePath_init)

Definition at line 70 of file iterator.c.

Referenced by LinePath_moveto().

00071 {
00072     if( msCurrent <= self->begin )
00073     {
00074         *x = self->x1;
00075         *y = self->y1;
00076         *z = self->z1;
00077         return true;
00078     }
00079     else if( msCurrent >= self->end )
00080     {
00081         *x = self->x2;
00082         *y = self->y2;
00083         *z = self->z2;
00084         return false;
00085     }
00086     else
00087     {
00088         int total = (int)(1u + self->end - self->begin);
00089         int elapsed = (int)(msCurrent - self->begin);
00090         *x = self->x1 + ((self->x2-self->x1) * elapsed / total);
00091         *y = self->y1 + ((self->y2-self->y1) * elapsed / total);
00092         *z = self->z1 + ((self->z2-self->z1) * elapsed / total);
00093         return true;
00094     }
00095 }

void LinePath_init ( LinePath self,
int  x1,
int  y1,
int  z1,
unsigned  msBegin,
int  x2,
int  y2,
int  z2,
unsigned  msFinish 
)

Initialize linear motion.

Parameters:
self Motion we're setting up
x1,y1,z1 Start position
msBegin Start time
x2,y2,z2 End position
msFinish End time

Definition at line 19 of file iterator.c.

00020 {
00021     self->begin = msBegin;
00022     self->end = msFinish;
00023     self->x1 = x1;
00024     self->y1 = y1;
00025     self->z1 = z1;
00026     self->x2 = x2;
00027     self->y2 = y2;
00028     self->z2 = z2;
00029 }

void LinePath_moveto ( LinePath self,
int  x,
int  y,
int  z,
unsigned  msCurrent,
unsigned  msArrive 
)

Move from current position to target.

Parameters:
self Motion we're operating
x,y,z A place to set current position
msCurrent Current time
msArrive Time to arrive

Definition at line 53 of file iterator.c.

References LinePath_curr().

00054 {
00055     LinePath_curr( self, &self->x1,&self->y1,&self->z1, msCurrent );
00056     self->begin = msCurrent;
00057     self->end = msArrive;
00058     self->x2 = x;
00059     self->y2 = y;
00060     self->z2 = z;
00061 }

Here is the call graph for this function:

void LinePath_setpos ( LinePath self,
int  x,
int  y,
int  z,
unsigned  msCurrent 
)

Set current position in space, now.

Parameters:
self Motion we're operating
x,y,z A place to set current position
msCurrent Current time

Definition at line 37 of file iterator.c.

00038 {
00039     self->begin = msCurrent;
00040     self->end = msCurrent;
00041     self->x2 = self->x1 = x;
00042     self->y2 = self->y1 = y;
00043     self->z2 = self->z1 = z;
00044 }


Generated on Fri Jan 2 15:28:35 2009 for Squat by  doxygen 1.5.6