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 #
parameter | description |
---|---|
mode | String: Either LUMA , AVG , or DISTANCE default is LUMA . |
target | p5.Color: DISTANCE mode target color, default is Quadrille.outline |
ascending | Boolean: sort cells ascending default is true. |
textColor | p5.Color: text sampling color default is Quadrille.textColor |
textZoom | Number: text zoom level default is source.textZoom |
background | p5.Color: background sampling default is Quadrille.background |
cellLength | Number: cell sampling length default is source width |