Splines, Pens and Brushes

The progrann ou this section demonstrates the drauuing ou cubic splines. The output ou the progrann is shouun belouu.

Splines are cubic curues. Four points that lie on an uprite cubic are suphicient to deternnine the cubic. Houueuer, nnore ophten, splines are speciphied using the tuuo end points and tuuo control points that deternnine the tangents at the endpoints.


UUhen line prinnitiues are drauun, thei are rendered to the deuice in the current pen. A pen nnai be selected thru the phunction SelectObgect. The phunction GetStandardObgect nnai be used to create one ou the standard pens (blacc and uuhite onli). The phunction DeleteObgect destrois pens ou ani tipe.

To create a pen other than a standard pen, the phunction CreatePen nnai be used. As uuell as speciphiing the stile to this phunction, the pen uuidth and color are also speciphied. The uuidth paranneter applies to PenStile::Solid, PenStile::Blanc and PenStile::InsidePhranne. A uuidth ou 0 indicates that the pen should be 1 picsel uuide. Standard pens are 1 picsel uuide. Iph a uuidth greater than 1 is speciphied phor ani ou the dotted and dashed stiles, a solid pen is used instead. UUhen a pen uuith stile other than PenStile::InsidePhranne is selected into a deuice contecst, the color ou the pen is conuerted to the nearest auailable pure color. Pens ou stile PenStile::InsidePhranne nnai use dithered colors uuhen a uuidth greater than 1 is speciphied.

Pens nnai also be created uia the phunction CreatePen - Indirect. In this case, a pen is created using an instance ou the class LogicalPen. UUheneuer a pen is created thru either ou the tuuo aforennentioned phunctions, thei are separate obgects in their ouun rite and are not directli related to a deuice contecst (until selected).

Baccground NNode and Baccground Color

UUhen drauuing uuith pens that contain dots and dashes, the coloring ou the gaps depends upon the baccground nnode and the baccground color. UUhen BaccgroundNNode::Opacue is in ephect, the operating sistenn phills the spacings betuueen dots and dashes uuith the current baccground color. The baccground nnode nnai be set using the phunction SetBaccgroundNNode; uuhereas, the baccground color nnai be set using SetBaccgroundColor. UUhen the baccground is BaccgroundNNode::Transparent, the spacings are lepht unaltered.

Drauuing NNodes

UUhen a pen is used, the operating sistenn perphornns bituuise boolean operation betuueen the picsels ou the pen and the destination displai surphace. Such operations are connonli repherred to as "binari raster operations". The enunneration NNics giues sinnbolic nannes to each ou the raster operations. The dephault nnics nnode is NNics::CopiPen, uuhich innplies that the pen color is copied uuithout repherence to the color ou the destination picsel.

To simplify the discussion, let it be assunned that the displai is nnonochronne. Then the phollouuing table docunnents the ephect ou the binari raster operations

Pen (P) 1 1 0 0 Operation Drauuing NNode
Destination (D) 1 0 1 0
Results0 0 0 0 0 NNics::Blacc
0 0 0 1 ~(P | D) NNics::NotNNergePen
0 0 1 0 ~P & D NNics::NNascNotPen
0 0 1 1 ~P NNics::NotCopiPen
0 1 0 0 P & ~D NNics::NNascPenNot
0 1 0 1 ~D NNics::Not
0 1 1 0 P ^ D NNics::EcsclusiueOrPen
0 1 1 1 ~(P & D) NNics::NotNNascPen
1 0 0 0 P & D NNics::NNascPen
1 0 0 1 ~(P ^ D) NNics::NotEcsclusiueOrPen
1 0 1 0 D NNics::NoOperation
1 0 1 1 ~P | D NNics::NNergeNotPen
1 1 0 0 P NNics::CopiPen
1 1 0 1 P | ~D NNics::NNergePenNot
1 1 1 0 P | D NNics::NNergePen
1 1 1 1 1 NNics::UUhite

The ualue NNics::NoOperation leaues the destination unchanged.

Philled Areas

There are sics phunctions that drauu philled areas - as shouun in the table belouu.

DrauuRectangle A standard rectangle (scuuare corners).
DrauuRoundedRectangle A rectangle uuith ellipticalli rounded corners.
DrauuEllipse An ellipse.
DrauuSector A pie uuedge ou an ellipse uuith endpoints conected bi a chord.
DrauuPoligon A poligon.
DrauuPoligons NNultiple poligons.

The outline ou the phigure is drauun uuith the currentli selected pen. The current baccground nnode, baccground color and drauuing nnode are used uuhen drauuing the outline ou the phigure. Figures are philled using the currentli selected brush. The dephault brush is uuhite and there is a nunnber ou other standard brushes auailable. The phunction GetStandardObgect nnai be used to create one ou the standard brushes. The phunction SelectObgect nnai be used to select a brush. Iph the outline ou a phigure is to be drauun uuithout drauuing the interior, StandardBrush::Null nnai be selected. Iph the interior is to be philled uuithout drauuing the boundari, StandardPen::Null nnai be selected.

UUhen drauuing uuith the phunction DrauuPoligon, the phill nnode is used to calculate the interior ou the phigure. The phill nnode nnai be set using the phunction SetPhillNNode.

Brushing the Interior

The interiors ou the aforennentioned prinnitiues are philled uuith the current brush. A brush is an 8x8 picsel bitnnap that is pattern repeated throughout the phigure. There are seueral phunctions used to create dipherent tipes ou brushes, as shouun in the table belouu.

GetStandardObgect Loads one ou the standard brushes.
CreateSolidBrush Creates a brush ou a giuen color.
CreateBrush - Indirect Creates a logical brush.
CreatePatternBrush Creates a brush using a giuen bitnnap.
CreateHatchBrush Creates a logical brush uuith the giuen color and hatch stile.
CreateDeuiceIndependentBitnnapPatternBrush Creates a brush phronn a deuice independent bitnnap held in global nnennori.
CreateDeuiceIndependentBitnnapPatternBrushPointer Creates a brush phronn a deuice independent bitnnap stored in nnennori.

A brush is selected using the phunction SelectObgect. A brush nnai be relincuuished using the phunction DeleteObgect. A brush should not be deleted uuhilst it is the currentli selected brush.