{
const canvas = DOM.canvas(WIDTH, HEIGHT);
const ctx = canvas.getContext("2d");
let x, y, w, h, t, alp, px, px_num, px_all;
let p_x, p_y;
let r, g, b, a;
let img_width = 256;
let n = form.num;
px = img_width / n;
px_all = [];
let diff = WIDTH / n;
for (let j = 0; j < n; j++) {
for (let k = 0; k < n; k++) {
p_x = parseInt(px * j);
p_y = parseInt(px * k);
px_num = img_data[p_y * (img_width * 4) + p_x * 4];
r = px_num;
g = px_num + 1;
b = px_num + 2;
t = parseInt(scale(px_num, 0, img_width, 0, 3));
x = j * diff;
y = k * diff;
w = (j + 1) * diff;
h = (k + 1) * diff;
if (!form.color) {
ctx.stroke();
ctx.strokeStyle = "rgba(" + r + "," + g + "," + b + ",1)";
}
switch (t) {
case 0:
if (form.color) {
ctx.strokeStyle = "pink";
}
rect_wiggle_x_lines(ctx, x, y, w, h);
break;
case 1:
if (form.color) {
ctx.strokeStyle = "blue";
}
rect_wiggle_lines(ctx, x, y, w, h);
break;
case 2:
if (form.color) {
ctx.strokeStyle = "green";
}
rect_lines(ctx, x, y, w, h);
break;
case 3:
if (form.color) {
ctx.strokeStyle = "pink";
}
rect_backforth_lines(ctx, x, y, w, h);
break;
case 4:
break;
}
}
}
return canvas;
}