Visio fill, line and end patterns

Created by: gwideman, Jan 12, 2012 12:23 am
Revised by: gwideman, Jan 15, 2012 2:46 pm (10 revisions)

Overview

Visio provide the capability for defining custom:
  • Patterns that apply Fill to areas
  • Patterns that apply dashes or more complicated "fill" to lines
  • Patterns that function as templates for line ends -- such as custom arrow heads.
The process for defining these custom patterns is similar to the process for creating a shape master. At its core, it involves creating a master, opening the drawing page editor for that master, and drawing some simple geometry. Developing Visio Solutions has some instructions:

Background

Beyond the basics of creating and defining a custom pattern, there are quite a few options to choose, nuances to be aware of, and idiosyncratic interactions. Hence this page which captures notes on the structure and function of Visio's Fill, Line and LineEnd patterns.
The main issue is that various aspects of a custom pattern render in variable ways in response to settings on the Shape which they adorn.
Unlike ordinary Masters, when a Pattern Master is applied, this does not create a separate instance shape. Rather, a Pattern Master is only referenced by an existing Shape instance, for used in rendering the fill, line or line end. So unlike Shape instances, there is no separate Pattern instance which could contain settings unique to that particular fill, line or line end.
However, there are certain variables within a Pattern Master which become parameters during the rendering process, which cause the pattern to respond to certain values in the instance Shape which it adorns. For example, when Line and Line End patterns are rendered, they can be sized according to the LineWeight of the line that they adorn. Also, colors selected in the instance Shape are used in the rendering of the custom Fill, Line and LineEnd patterns. Details below.

References

Pattern Type and Options

The overall character of a pattern master is set by the bitmap in Master.PatternFlags, as follows.
Feature
Constant
Value
Description
Type of pattern

(choose one)

visMasIsLinePat
0x1
Selects Line Pattern

visMasIsLineEnd
0x2
Selects Line end pattern

visMasIsFillPat
0x4
Selects Fill pattern
Line pattern mode

(choose one, plus optional scaling)

visMasLPTileDeform
0
Stretches the pattern master vertically so that master height = LineWeight. Visio approximately maintains the aspect ratio of the pattern [Note 2], repeating it along the line, and warping it around curves to create a continuous effect.

visMasLPTile
0x10
Repeats multiple instances of pattern along curve without bending the individual instances. [Note 2]

visMasLPStretch
0x20
Stretches and bends a single instance of pattern along the line. Generally this means that the aspect ratio is much more "horizontal" than vertical.

visMasLPAnnotate
0x30
Repeats multiple instances of pattern to creates “string of beads effect.
Line pattern scaling
visMasLPScale
0x40
If set causes pattern to scale according to drawing page. Otherwise causes pattern to size proportional to LineWeight. [Note 1]
Line end pattern mode

(choose one, plus optional scaling)

visMasLEDefault
0x0
Line end oriented according to orientation of end of line.

visMasLEUpright
0x100
Line end orients “upright” regardless of orientation of end of line.
Line end scaling
visMasLEScale
0x400
If set causes pattern to scale according to drawing page. Otherwise causes pattern to size proportional to LineWeight. [Note 1]
Fill pattern mode

(choose one, plus optional scaling)

visMasFPTile
0
Tiles multi copies of pattern in the fill area.

visMasFPCenter
0x1000
Centers single copy of pattern in fill area.

visMasFPStretch
0x2000
Stretches single copy of pattern in fill area.
Fill pattern scaling
visMasFPScale

If pattern is from scaled page and used on scaled drawing page, then this flag tells pattern to draw so scaled dimension is correct. Presumably most useful with FPTile. [Note 1]




Note 1: The scaling options are for use on scaled drawings. On non-scaled drawings, turn this option off, which will cause (on line and line end patterns) the pattern to respond to the weight of the line.
Note 2: The number of actual number of repeats N along the line is such that N is exact real number of patterns that would stretch to the required length, rounded up or down to nearest integer, but always >= 1.

Custom Line Pattern

Draw the Master assuming that horizontal in the master corresponds to the direction along the adorned line, whereas vertical in the master corresponds to the width of the line.
Pattern
Special value
Corresponds to Shape this way
Conditions
LineWeight
0 pt
Shape's LineWeight
Line pattern scaling OFF
Height
---
For Line pattern renders at a scale such that its height fills Shape's LineWeight
Line pattern scaling OFF
Mode: visMasLPStretch,
visMasLPTileDeform
LineColor
FillForegnd
FillBknd
0 (black)
Rendered using Shape's LineColor

Page size or Group alignment box
Pattern master's shape(s) are ungrouped
Visio uses the master's page as the overall region of the pattern.


Pattern master shapes are grouped
Visio uses the group's alignment box (Width X Height) as the pattern region.

Features and Idiosyncracies

  • If you draw geometry outside the page (or alignment box if grouped) then this will render outside the bounds that the page/alignment box would normally render to. Depending on the line pattern mode, this can result in drawing outside the normal width of the line, or overlapping of consecutive repetitions of the pattern , and so on.
  • Setting a custom line pattern causes the end of the line to adopt the appearance of a square end cap, even when LineCap = Round. (But NURBS seem to render smoothly as they do when LineCap = Round, despite the square end cap appearance.) See discussion below.
  • Using a bitmap image in the Line End master causes Visio to use only the image as the pattern, and no other geometry.

Custom Line End

The adorned Shape influences the custom Line End in a manner similar to its influence on the custom Line pattern, with additional sizing considerations.
Draw the master assuming that horizontal in the master corresponds to the direction along the adorned line, whereas vertical in the master corresponds to the width of the line (for pattern mode visMasLEDefault). The line will approach the Line End from the left.
Pattern
Special value
Corresponds to Shape this way
Conditions
LineWeight
0 pt
Shape's LineWeight
Line end pattern scaling OFF
Height
---
When the line's Begin/EndArrowSize is set to Medium, Visio renders the Line End pattern at a scale such that its height equals the Shape's LineWeight. (Other Begin/EndArrowSize cause the Line End to draw larger or smaller.)
This is similar to the scaling of line patterns (visMasLPStretch, visMasLPTileDeform modes), however for line end patterns you normally want some line-end geometry outside this bound, which will require, in the Master, drawing outside the alignment box.
Line end pattern scaling OFF
LineColor
FillForegnd
FillBknd
0 (black)
Rendered using Shape's LineColor

Alignment box
Left edge
Visio stops drawing the main line at the left edge of the pattern's alignment box.
(Assuming Shape's LineCap = Square, not extended. (Probably also for LineCap = Round combined with custom Line Pattern. What happens in extended case?)
Line end pattern scaling OFF
Pin location

Visio will position the line end so that the Pin is located at the line's end-point (ie: attachment point, BeginX/Y or EndX/Y)

Custom Fill Pattern

Pattern
Special value
Corresponds to Shape this way
Conditions
LineColor
FillForegnd
FillBknd
0 (black)
Rendered using Shape's FillBkgnd color (“Fill Pattern Color” in Fill dialog)

LineColor
FillForegnd
FillBknd
1 (white)
Rendered using Shape's FillForegnd (“Fill Color” in Fill Dialog)
Line pattern scaling OFF

Tricks and Tips

Black and almost black

Where you use black in a pattern, Visio will render the pattern according to the LineColor or FillColor of the adorned shape. So if you need the pattern to contain some black shapes or lines that should not be recolored, in the master set those shapes to a color that is near to black but not quite.

Getting a precise join for Line patterns and Line Ends

It can seem tricky to get a precise join between areas of color that are adjacent in line pattern repetitions (for the most-useful visMasLPTileDeform mode), and similarly between line pattern and line end.
[image]
In the master, the problem stems from the width of lines used to surround areas of fill. If you exclude the lines (eg, set them invisible) they still take up space, and your region of color will be slightly small, and cause the rendered line to be slightly narrow in width (perhaps not matching the Line End), or will leave gaps between pattern repetitions, or next to the Line End. If you include the lines, then half the width of the line may be outside the alignment box or master page, and this will make the rendered line slightly fatter, and cause overlaps between line pattern repetitions. (The overlaps may not be a concern normally, but do show up if you set some level of transparency on the adorned line shape.)
Here are some approaches to this problem:
  • Include the surrounding line, but set it super thin, say 0.01pt. This improves the situation, but doesn't fix it, as Visio appears to round when rendering, and may round adjacent pattern repetitions or line ends differently.
  • Set GeometryN.NoLine to TRUE: I don't remember the result of this, but it didn's seem to do the job.
  • For the geometry lines that will border on neighboring patterns, set them to "MoveTo" instead of "LineTo". This produced the most reliably matching seams.
  • Another possible strategy to reduce seams between pattern repetitions (visMasLPTileDeform mode) is to create a super-long Line pattern master. This does reduce the number of seams. But unfortunately if the adorned line is shorter than the length of the tile (accounting for scaling pattern Height to adorned line Width), then Visio compresses the tile lengthwise, rather than cropping it. This is probably not the desired effect.

Issues that introduce obstacles for Patterns

Visio 2010:
  • Poor path calculation for wide Freeform lines, Cap = Round, custom Line Ends and custom Line Pattern all interact.
    • Poor path calculation for Freeform lines (NURBS) on wide lines (high LineWeight), resulting in extraneous chunks of line sticking out.
      • This may be only on screen, varies with screen zoom, and may print correctly
      • Seems to be a problem only for Line Cap = Square or Extended, and not a problem for Line Cap = Round.
      • If we commit to using Line Cap = Round, then we have to design Line Ends to allow for the round end cap of the line.
        • But then the line end will overlap a shape that the line needs to connect to.
        • And Line Cap = Round does not actually produce round caps when using custon Line Patterns! (But does produce the no-protruding-chunks smooth line.)
          • So for lines using a custom Line Pattern, a custom Line End can be designed as though it is being used on a Cap = Square line.