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]

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]