Skip to content

Commit

Permalink
destructuring assignment in drawQuadrille;ver 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nakednous committed Nov 23, 2021
1 parent f79350f commit a33c3ae
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 22 deletions.
15 changes: 13 additions & 2 deletions examples/convolution/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@ function setup() {
function draw() {
background('#060621');
if (image_mode) {
drawQuadrille(quadrille, 0, 0, 20 / (2 ** scl), 1.6 / (2 ** scl), quadrille === orig ? 'magenta' : 'cyan');
drawQuadrille(quadrille,
{
LENGTH: 20 / (2 ** scl),
outlineWeight: 1.6 / (2 ** scl),
outline: quadrille === orig ? 'magenta' : 'cyan'
});
} else {
drawQuadrille(mask, 0, 0, 50, 2, 'magenta', false, 0.0625, 0.25);
drawQuadrille(mask,
{
LENGTH: 50,
min: 0.0625,
max: 0.25,
alpha: 255
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/from_other/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ function setup() {

function draw() {
background('#060621');
drawQuadrille(H, 2, 2, LENGTH, 2);
drawQuadrille(other, 2, 10, LENGTH, 2, 'magenta', true);
drawQuadrille(H, {x: 2, y: 2, LENGTH: LENGTH});
drawQuadrille(other, {x: 2, y: 10, LENGTH: LENGTH, board: true});
}
29 changes: 24 additions & 5 deletions examples/glyphs/sketch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ROWS = 20;
const COLS = 10;
const LENGTH = 20;
var t, T, L, Lbit, test;
var t, I, T, L, Lbit, test;
var quadrille;
var clone;
var x = 2, y = 2;
Expand Down Expand Up @@ -40,22 +40,41 @@ function setup() {
clone.reflect();
test = createQuadrille(4, int(random(1, 1048576)), color('#F0B25A'));
c.setBlue(255);
/*
I = createQuadrille([
[0, c, 0, 0],
[0, c, 0, 0],
[0, c, 0, 0],
[0, c, 0, 0],
]);
*/
I = createQuadrille([
[0, 0, 0, 0, 0, 0],
[0, 0, c, 0, 0, 0],
[0, 0, c, 0, 0, 0],
[0, 0, c, 0, 0, 0],
[0, 0, c, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
]);
}

function draw() {
background('#060621');
drawQuadrille(quadrille, x, y, LENGTH, 2, 'green');
//drawQuadrille(quadrille, x, y, LENGTH, 2, 'green');
drawQuadrille(quadrille, {x: x, y: y, LENGTH: LENGTH, outlineWeight: 2, outline: 'green'});
drawQuadrille(I, {x:2, y:12, LENGTH: LENGTH, outline:'blue'});
//drawQuadrille(test, x, y, LENGTH, 2, 'green', true);
drawQuadrille(clone, 2, 8, LENGTH, 0);
//drawQuadrille(clone, 2, 8, LENGTH, 0);
//drawQuadrille(L, 2, 12, LENGTH);
//drawQuadrille(Lbit, 2, 12, LENGTH);
//drawQuadrille(I, 2, 12, LENGTH, 2, 'blue');
}

function keyPressed() {
if (keyCode === UP_ARROW) {
quadrille.reflect();
} else if (keyCode === DOWN_ARROW) {
quadrille.rotate();
I.rotate();
}
if (key === 'a') {
x = x > 0 ? x - 1 : x;
Expand All @@ -76,7 +95,7 @@ function keyPressed() {
test.delete(test.height - 1);
}
if (key === 'p') {
console.log(test.toInt());
console.log(I.toInt());
}
if (key === 'r') {
quadrille.randomize();
Expand Down
6 changes: 5 additions & 1 deletion examples/imaging/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ function setup() {

function draw() {
background('#060621');
drawQuadrille(quadrille, 0, 0, 20 / (2 ** scl), 1.6 / (2 ** scl));
drawQuadrille(quadrille,
{
LENGTH: 20 / (2 ** scl),
outlineWeight: 1.6 / (2 ** scl),
});
}

function keyPressed() {
Expand Down
7 changes: 3 additions & 4 deletions examples/logic/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ function setup() {

function draw() {
background('#060621');
drawQuadrille(q1, x1, y1, LENGTH, 2, 'green', true);
drawQuadrille(q2, x2, y2, LENGTH, 2, 'blue', true);
drawQuadrille(q1, {x: x1, y: y1, LENGTH: LENGTH, outline: 'green', board: true});
drawQuadrille(q2, {x: x2, y: y2, LENGTH: LENGTH, outline: 'blue', board: true});
if (q3) {
drawQuadrille(q3, x3, y3, LENGTH, 2, 'magenta', true);
//drawQuadrille(q3, x3, y3, LENGTH, 2, 'magenta');
drawQuadrille(q3, {x: x3, y: y3, LENGTH: LENGTH, board: true});
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/memory/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function setup() {

function draw() {
background(/*'#060621'*/ '#007ACC');
drawQuadrille(board, 0, 0, LENGTH, 2, 'blue', true);
drawQuadrille(quadrille, x, y, LENGTH, 2, 'green');
drawQuadrille(board, {LENGTH: LENGTH, outline: 'blue', board: true});
drawQuadrille(quadrille, {x: x, y: y, LENGTH: LENGTH, outline: 'green'});
}

function keyPressed() {
Expand Down
2 changes: 1 addition & 1 deletion examples/mosaic/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function setup() {

function draw() {
background('#FDF6E3');
drawQuadrille(quadrille, x, y, LENGTH, 2, 'green');
drawQuadrille(quadrille, {x: x, y: y, LENGTH: LENGTH, outline: 'green'});
}

function keyPressed() {
Expand Down
4 changes: 2 additions & 2 deletions examples/rand/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function setup() {
function draw() {
background('#060621');
//drawQuadrille(quadrille, x, y, LENGTH, 2, 'green');
drawQuadrille(quadrille, 2, 12, LENGTH, 2, 'green');
drawQuadrille(r, x, y, LENGTH, 2, 'blue', true);
drawQuadrille(quadrille, {x: 2, y: 12, LENGTH: LENGTH, outline: 'green'});
drawQuadrille(r, {x: x, y: y, LENGTH: LENGTH, outline: 'blue', board: true});
}

function keyPressed() {
Expand Down
2 changes: 1 addition & 1 deletion examples/raster/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function setup() {

function draw() {
background('#060621');
drawQuadrille(quadrille, 0, 0, LENGTH, 2, 'green', true);
drawQuadrille(quadrille, {LENGTH: LENGTH, outline: 'green', board: true});
tri();
}

Expand Down
14 changes: 12 additions & 2 deletions p5.quadrille.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Quadrille {
/**
* Current library version.
*/
static version = '0.3.1';
static version = '0.4.0';

/**
* @param {Quadrille} quadrille1
Expand Down Expand Up @@ -601,7 +601,17 @@ class Quadrille {
return new Quadrille(...arguments);
}

p5.prototype.drawQuadrille = function(quadrille, x = 0, y = 0, LENGTH = 10, outlineWeight = 2, outline = 'magenta', board = false, min = 0, max = 0, alpha = 255) {
p5.prototype.drawQuadrille = function(quadrille,
{ x = 0,
y = 0,
LENGTH = 10,
outlineWeight = 2,
outline = 'magenta',
board = false,
min = 0,
max = 0,
alpha = 255
} = {} ) {
this.push();
this.translate(x * LENGTH, y * LENGTH);
this.stroke(outline);
Expand Down

0 comments on commit a33c3ae

Please sign in to comment.