Search Locate Previous Next Contents

chDefineTile – define new fill patterns

RainPro uses the first 8 ‘patterns’ to generate half-tones on low-colour devices (16- and 256-colour monitors and mono printers); patterns 9-15 are a simple set of hatchings, and numbers up to 39 are a selection of opacities and gradient fills. Any higher numbers may be defined using either the name of a bitmap file, a reference to an SVG gradient (see below) or a variation on one of the standard fills.

Note that there are some minor variations between output formats (PDF does not currently support the hatchings or bitmap fills, and SVG/VML do not support hatchings). The gradient fills look very similar on all output formats, but there are some inevitable small visual differences as the syntax for defining gradients is very different on the 3 formats.

Examples of Bitmap Fills

chDefineTile 32 'c:\windows\bubbles'
chDefineTile 67 (?8 8½15)

defines patterns 32 and 67. These can then be used anywhere a fill is required, for example:

chSet 'pattern' 3 14 32 67
chPie 5 4 3 2
View chClose

will cycle these patterns around the pie sectors.

Note that the sector colour will be ignored for sectors with bitmap fills – the pattern is assumed to be fully coloured already.

Augmenting a standard gradient fill
The way all the built-in gradients work is to ‘lighten up’ the base colour by stirring in white to make the target colour for the highlight. If you want to grade to an arbitrary colour, you can override the colour with:

 chDefineTile 77 '34+Fuchsia'

This will use the gradient pattern numbered 34 (numeric pattern ids only are allowed here) but will grade towards ‘Fuchsia’. Of course hex values are also allowed here as a way of specifying arbitrary colours.

Alternatively, you can simply vary the amount of white ‘stirred in’ by changing the target pattern number (the default is always to grade towards pattern-3):

 chDefineTile 101 '36+1'

This example will use the ‘spotlight’ gradient, but with a much brighter central highlight.

Working with custom gradients and filters in SVG
SVG allows you to define a wide range of gradient fills as named resources within the output page. If you want to extend the set of inbuilt gradients, you can use this function to reference the URL of the fill pattern (included in the chart definition), prior to setting it as the pattern attribute for any of the chart, note or key boxes, or as an item in the Patterns cycle.

 chDefineTile 17 '#spotlight'
 chDefineTile 21 'filter:url(#MyFilter); fill:url(#fill1)'

In the second example, a filter is combined with a pre-defined fill. You can also set the opacity of the tile here:

chDefineTile 24 'fill:url(#fill2); opacity:0.25'

This will set up the defined fill pattern, but it will only be 25% opaque. Of course, any definitions you make here are completely platform-specific and will show as half-tone colour if the chart is rendered to PDF, VML or a raster format.

See also ...
chInclude – add arbitrary content (SVG filters)
Patterns – pattern cycle


Continue to: chDraw – add arbitrary polylines
© Copyright Causeway Graphical Systems Ltd 2003