DrawBresenhamStyleLine

Draws an OS/2 style styled, single pixel wide line with bresenham parameters.

Declaration

void NAPI GA_2DRenderFuncs::DrawBresenhamStyleLine(
    N_int32 x1,
    N_int32 y1,
    N_int32 initialError,
    N_int32 majorInc,
    N_int32 diagInc,
    N_int32 count,
    N_int32 flags,
    N_int32 transparent)

Prototype In

snap/graphics.h

Parameters

x1

X1 coordinate

y1

Y1 coordinate

initialError

Initial error term

majorInc

Major increment factor for error term

diagInc

Diagonal increment factor for error term

count

Number of pixels to draw

flags

Flags to control drawing (GA_BresenhamLineFlagsType)

transparent

True for a transparent background

 

Description

This function is similar to the regular DrawStippleLineInt function, except that the bresenham parameters for the line are pre-computed and passed to this function. Allowing the application to pre-compute the bresenham parameters allows for accurate clipping as the bresenham parameters can be computed for the unclipped line, and initialised to the start of the clipped line segement. This function is used by OS/2 display drivers to get accurate line clipping. The values passed to the function for a regular integer line can be computed as follows:

flags = gaLineXPositive | gaLineYPositive | gaLineXMajor
    | gaLineDoLastPel;
if ((absDeltaX = x2 - x1) < 0) {
    absDeltaX = -absDeltaX;
    flags &= ~gaLineXPositive;
    }
if ((absDeltaY = y2 - y1) < 0) {
    absDeltaY = -absDeltaY;
    flags &= ~gaLineYPositive;
    }
if (absDeltaY > absDeltaX) {
    SWAP(absDeltaX,absDeltaY);
    flags &= ~gaLineXMajor;
    }
majorInc = 2 * absDeltaY;               // 2 * dy
initialError = majorInc - absDeltaX;    // 2 * dy - dx
diagInc = initialError - absDeltaX;     // 2 * (dy - dx)

See Also

DrawStyleLineInt, DrawLineInt, SetLineStyle

Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com