22.03.2015 Views

DLI Implementation and Reference Guide - Datalogics

DLI Implementation and Reference Guide - Datalogics

DLI Implementation and Reference Guide - Datalogics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12.14 <strong>DLI</strong> <strong>Implementation</strong> <strong>and</strong> <strong>Reference</strong> <strong>Guide</strong><br />

"C" Example: Filling An Area With A Pattern<br />

DLPDFPATTERN<br />

*Pattern;<br />

DLPDFCONTENT<br />

*PatContent, *PageCont;<br />

PDGraphicState Concepts <strong>and</strong> State; Facilities: <strong>Guide</strong> to the DL Pager Composition System<br />

ASFixedMatrix Matrix;<br />

ASFixedRect BBox;<br />

/* Initialize the graphics state */<br />

State.strokeColorSpec.space = State.fillColorSpec.space =<br />

PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray"));<br />

State.strokeColorSpec.value.color[0] =<br />

State.strokeColorSpec.value.color[0] = 0;<br />

State->GState.miterLimit = fixedTen;<br />

State->GState.flatness = fixedOne;<br />

State->GState.lineWidth = fixedTwo;<br />

/* Draw the pattern “tile” */<br />

PatContent = dlpdfcontentcreate (Doc);<br />

dlpdfcontentline (PatContent, &State, kPDEStroke,<br />

0, 0, fixedTen + fixedTwo, fixedTen + fixedTwo);<br />

BBox.left = BBox.bottom = 0;<br />

BBox.right = BBox.top = fixedTen + fixedTwo;<br />

Matrix.a = Matrix.d = fixedTwo / 3;<br />

Matrix.b = Matrix.c = Matrix.h = Matrix.v = 0;<br />

Pattern = dlpdfpatterncreate (Doc, PatContent, &BBox, &Matrix,<br />

FALSE, 1, BBox.right - fixedTwo, BBox.top - fixedTwo);<br />

/* Set this pattern as the fill pattern */<br />

dlpdfcontentusefillpattern (PageCont, Pattern);<br />

/* Draw <strong>and</strong> fill the structure */<br />

...<br />

/* Cancel the fill pattern */<br />

dlpdfcontentusefillpattern (PageCont, NULL);<br />

NOTE: A fill pattern is never destroyed. It becomes a part of the document, <strong>and</strong><br />

the space used to define the pattern will be freed automatically when the<br />

document is freed.<br />

Repeating Pattern <strong>Reference</strong>s<br />

Most often, you will want to create a repertoire of fill patterns that matches the<br />

capabilities of your existing composition engine or of the display devices you have

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!