crop(row, col, width, height, wrap)
Returns the rectangular region anchored at (row, col) as a new quadrille.
width > 0grows right,width < 0grows left.height > 0grows down,height < 0grows up.- If either
widthorheightis0(or non-finite), a warning is issued andundefinedis returned. - If
wrapistrue, indices wrap toroidally at the borders; whenfalse(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)
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
drawQuadrillecreateQuadrillecellLengthmouseRowmouseColrandcrop- p5.js
createCanvasbackgroundcolortextkeypositionfillcreateCheckboxcheckednoStrokechanged- 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.