Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Using TLinearDDA

These examples show how the TLinearDDA functions are used to obtain the pixels which most closely correspond to a line's specified start and end points.

Line A has a start point (3,10) and end point (22,6). The x-delta is therefore 22-3+1=20. The y-delta is 10-6+1=5. 5 goes into 20 exactly four times, so each step of the pixel line has four pixels in it.

SingleStep() begins with aPosition set to the start pixel aStart. The move is in the direction from aStart to aFinish. Thus for line A the values given after each use of SingleStep() are:

start point (3,10)

second point (4,10)

third point (5,10)

fourth point (6,10)

fifth point (7,11), etc.

SingleScanline() repeatedly moves one scan line at a time up/down the pixel line, giving the co-ordinates of the left most and right most pixels of the pixel line that are on the scan line moved to. It begins on the scan line containing aStart. The move is in the direction from aStart to aFinish.

For line A the values given after each use of SingleScanline() are:

aStartPosition

aEndPosition

TBool

1.

start point (3,10)

fourth point (6,10)

EFalse

2.

fifth point (7,9)

eighth point (10,9)

EFalse

3.

ninth point (11,8)

twelfth point (14,8)

EFalse

4.

thirteenth point (15,7)

sixteenth point (18,7)

EFalse

5.

seventeenth point (19,6)

finish point (22,6)

ETrue

For line B the values given after each use of SingleScanline() are:

aStartPosition

aEndPosition

TBool

1.

start point (24,17)

start point (24,17)

EFalse

2.

second point (24,16)

second point (24,16)

EFalse

3.

third point (24,15)

third point (24,15)

EFalse

4.

fourth point (24,14)

fourth point (24,14)

EFalse

5.

fifth point (25,13)

fifth point (25,13)

EFalse

etc.

etc.

etc.

13.

thirteenth point (27,5)

thirteenth point (27,5)

EFalse

14.

finish point (27,4)

finish point (27,4)

ETrue

NextStep() repeatedly moves along the pixel line one step of pixels at a time, giving the pixel coordinates of the start of each step. It begins on the step of pixels containing aStart. The move is in the direction from aStart to aFinish.

For line A the values given after each use of NextStep() are:

aPosition

TBool

1.

start point (3,10)

EFalse

2.

fifth point (7,9)

EFalse

3.

ninth point (11,8)

EFalse

4.

thirteenth point (15,7)

EFalse

5.

seventeenth point (19,6)

EFalse

6.

finish point (22,6)

ETrue

For line B the values given after each use of NextStep() are:

aPosition

TBool

1.

start point (24,17)

EFalse

2.

fifth point (25,13)

EFalse

3.

eighth point (26,10)

EFalse

4.

twelfth point (27,6)

EFalse

5.

finish point (27,4)

ETrue