Creates a checkerboard image

Description

Creates a checkerboard image of specified dimensions and saves to an input file path. The dimensions of the checkerboard are specified by the number of internal corners (the number of squares minus one).

Usage

1
2
3
4
drawCheckerboard(nx, ny, square.size, file = NULL, 
                 margin.x = c(round(square.size/2), round(square.size/2)),
                 margin.y = c(round(square.size/2), round(square.size/2)),
                 filename = NULL, ...)

Arguments

nx

the number of internal corners in the horizontal direction (the number of squares in each row minus one).

ny

the number of internal corners in the vertical direction (the number of squares in each column minus one).

square.size

the square size in pixels.

file

the file path and name to which the image should be saved. The filename must be a valid image filename. Acceptable extensions are: jpg, jpeg, bmp, png and tiff.

margin.x

the margin in pixels on the left and right sides of the checkerboard pattern.

margin.y

the margin in pixels on the top and bottom of the checkerboard pattern.

filename

Duplicate with file. Included for backward compatibility with previous version.

...

further arguments to be passed to the image function corresponding to the extension in filename (e.g. compression, quality, etc.).

Details

This function requires the grid package. The image type is determined automatically from the filename and the corresponding image writing function is called.

Value

returns null device

Author(s)

Aaron Olsen

See Also

readCheckerboardsToArray

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## NUMBER OF INTERNAL CORNERS IN THE HORIZONTAL DIMENSION
## NUMBER OF ROWS OF SQUARES MINUS ONE
nx <- 21

## NUMBER OF INTERNAL CORNERS IN THE VERTICAL DIMENSION
## NUMBER OF COLUMNS OF SQUARES MINUS ONE
ny <- 14

## SQUARE SIZE IN PIXELS
square.size <- 200

## WHERE TO SAVE THE FILE
filename <- paste0("checkerboard_", nx, "_", ny, "_", square.size, ".jpeg")

## Not run: 
## DRAW CHECKERBOARD
## FILE WILL BE CREATED IN CURRENT WORKING DIRECTORY
drawCheckerboard(nx=nx, ny=ny, square.size=square.size, filename=filename)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.