Visualize supports an advanced feature set for line patterns. You can use one of the pre-defined line patterns by defining it in the active portfolio and instructing the segment to use that pattern. For example, to set the "dashdot" line pattern, you could use the following code:
For a list of all pre-defined line patterns, as well as their names, see the appendix section on lines.
Custom line patterns are also available. To define a custom pattern, it is necessary to understand the hierarchy involved. Line patterns are comprised of one or more parallels. Each parallel describes a set of elements which will be drawn along the path of a line. The elements can be solid pixels, blank pixels, or glyphs. The object hierarchy is shown below:
The procedure for building these objects is described in the steps below:
For this example, a double line composed of two parallels will be built: a solid blue and a dashed orange line. Working from the bottom of the hierarchy to the top, the first step is to initialize the HPS::LinePatternElements. The code below initializes the individual line patterns for use within the line as a whole. Note that a dashed line is actually made of two elements: a repeating pattern of solids and blanks.
Now that the HPS::LinePatternElement objects are initialized, the next step is to assemble them into a collection. Like the HPS::GlyphElement objects discussed in section 4.5, they all need to be combined into an array. Since a line made of two parallels is desired, two arrays are needed. The order of the elements in the array will determine their order in the rendered line.
Each HPS::LinePatternElementArray now needs to be made into a parallel. The parallel objects allow the offset (distance between the parallels and the line path) and weight to be set. The parallels live inside a HPS::LinePatternParallelKitArray.
A HPS::LinePatternKit is used to conglomerate all of the line pattern data. After the kit is built, the construction phase of the line pattern is complete.
Before using the line pattern, it must be defined in a portfolio. Don't forget to set the portfolio on the segment you intend to use it on. Portfolios are introduced in section 4.1.
At this point, the line pattern is defined and ready to use. As line patterns are controlled at the segment level, the pattern must be set there.
Glyphs can also be used as elements in a line pattern. To do so, the glyph must be already defined (see section 4.5 for a discussion on defining glyphs). The steps for using glyphs follow the same basic principles as other types of line pattern elements:
The remaining steps are nearly identical to building a normal line pattern. Note the call to SetInsetBehavior. The inset behavior will determine whether the glyph is drawn as a distinct element (Inline), overlapping the line elements (Overlap), or a length-trimmed hybrid (Trim). The screenshot below shows an example of all three behaviors.