Sort

sort() #

Sort source cells according to their coloring.

Example #

code
Quadrille.background = 'black';
let ascending;
let source, target;
let array;

function preload() {
  array = [];
  for (let i = 1; i <= 13; i++) {
    array.push(loadImage(`p${i}.jpg`));
  }
  array.push(210);
  array.push('🐒');
  array.push(80);
}

function setup() {
  createCanvas(400, 900);
  source = createQuadrille(4, array);
  target = source.clone();
  target.sort();
  ascending = createCheckbox('ascending', true);
  ascending.position(10, height / 2);
  ascending.style('color', 'yellow');
  ascending.input(() => target.sort( { ascending: ascending.checked() }));
}

function draw() {
  background(Quadrille.background);
  drawQuadrille(source);
  drawQuadrille(target, { row: 5 });
}

Syntax #

sort([{[mode], [target], [ascending], [textColor], [textZoom], [background], [cellLength]}])

Parameters #

parameterdescription
modeString: Either LUMA, AVG, or DISTANCE default is LUMA.
targetp5.Color: DISTANCE mode target color, default is Quadrille.outline
ascendingBoolean: sort cells ascending default is true.
textColorp5.Color: text sampling color default is Quadrille.textColor
textZoomNumber: text zoom level default is source.textZoom
backgroundp5.Color: background sampling default is Quadrille.background
cellLengthNumber: cell sampling length default is source width