14.2 Patterns and Stencils

Patterning creates a bounded rectangular arrangement of designs, like a checkerboard. Drawing a pattern draws a different design in each rectangular cell of the pattern. To create an infinite pattern, apply make-rectangular-tile to a pattern. [annotate]

Note: Are patterns regions? 14.5 implies that by advising use of transform-region on them. [edit]-- Daniel Kochmanski 2018-08-16 05:50Z
 
Note:

Patterns are no regions. The region protocol does not apply to them. Only because transform-region is also defined on designs, does not make them regions. In so far a mention of transform-region as part of a design protocol would be called for.

There is different "overloading" with compose-in, compose-out and +nowhere+ being the same as +transparent-ink+ and +everywhere+ being +foreground-ink+. But: Areas have no colour. Or mathematically areas are sets of points, while designs are a mapping of the 2d plane to colour and opacity.

Further: Patterns are bounded, rectangular tiles are not. And thus rectangular tiles are no patterns.

[edit]-- Gilbert Baumann 2021-08-15 04:41Z
 
Note:

I agree that patterns are not regions.

I have doubts regarding "Patterns are bounded, rectangular tiles are not" - this paragraph says that patterning creates a bounded rectangular arrangement of designs, it is nowhere said that patterns are bounded themselves.

In contrary: "To create an infinite pattern, apply make-rectangular-tile to a pattern."

[edit]-- Daniel Kochmanski 2022-03-13 11:32Z
 

A stencil is a special kind of pattern that contains only opacities. [annotate]

make-pattern  array designs [Function]
          

Returns a pattern design that has (array-dimension array 0) cells in the vertical direction and (array-dimension array 1) cells in the horizontal direction. array must be a two-dimensional array of non-negative integers less than the length of designs. designs must be a sequence of designs. The design in cell (i,j) of the resulting pattern is the nth element of designs, if n is the value of (aref array i j). For example, array can be a bit-array and designs can be a list of two designs, the design drawn for 0 and the one drawn for 1. [annotate]

Each cell of a pattern can be regarded as a hole that allows the design in it to show through. Each cell might have a different design in it. The portion of the design that shows through a hole is the portion on the part of the drawing plane where the hole is located. In other words, incorporating a design into a pattern does not change its alignment to the drawing plane, and does not apply a coordinate transformation to the design. Drawing a pattern collects the pieces of designs that show through all the holes and draws the pieces where the holes lie on the drawing plane. The pattern is completely transparent outside the area defined by the array. [annotate]

Each cell of a pattern occupies a 1 by 1 square. You can use transform-region to scale the pattern to a different cell size and shape, or to rotate the pattern so that the rectangular cells become diamond-shaped. Applying a coordinate transformation to a pattern does not affect the designs that make up the pattern. It only changes the position, size, and shape of the cells' holes, allowing different portions of the designs in the cells to show through. Consequently, applying make-rectangular-tile to a pattern of nonuniform designs can produce a different appearance in each tile. The pattern cells' holes are tiled, but the designs in the cells are not tiled and a different portion of each of those designs shows through in each tile. [annotate]

This function is permitted to capture its mutable inputs; the consequences of modifying those objects are unspecified. [annotate]

[annotate]

pattern-width  pattern [Generic Function]
pattern-height  pattern [Generic Function]
          

These functions return the width and height, respectively, of the pattern pattern. [annotate]

[annotate]

make-stencil  array [Function]
          

Returns a pattern design that has (array-dimension array 0) cells in the vertical direction and (array-dimension array 1) cells in the horizontal direction. array must be a two-dimensional array of real numbers between 0 and 1 (inclusive) that represent opacities. The design in cell (i,j) of the resulting pattern is the value of (make-opacity (aref array i j)). [annotate]

This function is permitted to capture its mutable inputs; the consequences of modifying those objects are unspecified. [annotate]

[annotate]