crop(row, col, width, height, wrap)

Returns the rectangular region anchored at (row, col) as a new quadrille.

  • width > 0 grows right, width < 0 grows left.
  • height > 0 grows down, height < 0 grows up.
  • If either width or height is 0 (or non-finite), a warning is issued and undefined is returned.
  • If wrap is true, indices wrap toroidally at the borders; when false (default), out-of-bounds area is taken as empty.
  • Otherwise the result is always a quadrille of size |width| × |height|.

Example

(click on canvas, move the mouse, and press the arrow keys)

edit, then run

Syntax

crop(row, col, width, height, [wrap = false])

Parameters

Param Description
row Number: anchor row (the starting cell’s row)
col Number: anchor column (the starting cell’s column)
width Number: rectangle width; > 0 to the right, < 0 to the left; 0 disables
height Number: rectangle height; > 0 downward, < 0 upward; 0 disables
wrap Boolean: when true , indices wrap toroidally at borders; when false (default), out-of-bounds cells are taken as empty
What this page's examples use
p5.quadrille
drawQuadrille createQuadrille cellLength mouseRow mouseCol rand crop
p5.js
createCanvas background color text key position fill createCheckbox checked noStroke changed
JavaScript
Math.abs

Names the analysis can prove are called, and the line each one is documented on. Local variables and members of an unknown receiver are left out.