Introduction to PDF Color: Fun with tiling Patterns

Introduction to PDF Color: Fun with tiling Patterns

For today’s episode, We have old-time Ducky (from the silent-era before the talkies nearly ruined everything by revealing that Ducky’s voice actually squeaked).


Actually, this is the same old Ducky, rendered to grayscale, split apart by gray-scale level, vectorized with POTrace, and then recombined. We are going to use this PDF to demonstrate some other ways to make shades of gray; this time using tiling Patterns. The key to this is this illusion:


In this illusion we have a gray background upon which are white lines and black lines; in the square delineated with the black lines we see a darker gray than the outer square with its white lines, hence the illusion. But if you think of this printed on paper, gray is essentially created by varying the density of ink in an area, so if this illusion were printed on paper, your eyes would correctly be reporting that the inner square has a higher ink density than the area around it.

So now, what we are going to do with old-time Ducky is replace the deviceGray fills with tiling patterns whose content fills the tile with roughly the same amount of (black) ink as an entirely gray tile.

In this first variation, we are going to create a pattern of lines, varying the line width to control how much black will be in the tile.

The result (click to see full-size):


In this next variation, instead of using straight lines, we are going to draw sawtoothed lines.


And finally, instead of lines, we’ll draw rectangles to fill the tile area:


The code for replacing  DeviceGray fills with Pattern fills is basically the same:

Note that this code takes advantage that the recombined color shapes are all grouped together by color value, so it starts a new pattern when the grayscale color value changes.  If this assumption does not apply, then you would want another method of re-using  patterns for a given color value.

Start your free evaluation of Adobe PDF Library today.

Leave a Reply

Your email address will not be published. Required fields are marked *