Skip to content

Latest commit

 

History

History
86 lines (67 loc) · 1.6 KB

insert.md

File metadata and controls

86 lines (67 loc) · 1.6 KB
weight draft
5
false

insert()

Inserts an empty row into the quadrille.

Example

(click any row; press any key to reset)
{{< p5-global-iframe quadrille="true" width="425" height="425" >}} use strict; Quadrille.cellLength = 20; let quadrille;

function setup() { createCanvas(400, 400); reset(); }

function draw() { background('orange'); drawQuadrille(quadrille); }

function mouseClicked() { if (quadrille.height < 20) { quadrille.insert(quadrille.mouseRow); } }

function keyPressed() { reset(); }

function reset() { quadrille = createQuadrille(20, 10, 50, color('red')); quadrille.rand(50, color('green')).rand(50, color('blue')). rand(50, color('cyan')); } {{< /p5-global-iframe >}}

{{< details title="code" open=false >}}

Quadrille.cellLength = 20;
let quadrille;

function setup() {
  createCanvas(400, 400);
  reset();
}

function draw() {
  background('orange');
  drawQuadrille(quadrille);
}

function mouseClicked() {
  if (quadrille.height < 20) {
    quadrille.insert(quadrille.mouseRow);
  }
}

function keyPressed() {
  reset();
}

function reset() {
  quadrille = createQuadrille(20, 10, 50, color('red'));
  quadrille.rand(50, color('green')).rand(50, color('blue')).
            rand(50, color('cyan'));
}

{{< /details >}}

Syntax

insert(row)

Parameters

parameter description
row Number: number of the row to be inserted [[0..height]]({{< ref "height" >}})]