xxxxxxxxxx
57
let dotSize = 1;
function setup()
{
createCanvas(windowWidth, windowHeight);
background(40);
strokeWeight(dotSize);
stroke(255);
let base = floor(0.75 * height / dotSize);
for (let i = 0; i < width / dotSize; ++i)
{
let x = i * 3;
let offset = FactorCount(i + 1, 2);
let y0 = base;
let y1 = y0 - pow(offset, 2.5) * 2;
Line(x, y0, x, y1);
}
print(LogB(50, 2));
}
function FactorCount(n, f)
{
let c = 0;
let divided = n / f;
while (floor(divided) === divided)
{
++c;
n = divided;
divided = n / f;
}
return c;
}
function Line(x0, y0, x1, y1)
{
let n = 0.5;
x0 = floor(x0) + n;
y0 = floor(y0) + n;
x1 = floor(x1) + n;
y1 = floor(y1) + n;
line(x0 * dotSize, y0 * dotSize,
x1 * dotSize, y1 * dotSize);
}
function LogB(n, b) { return log(n) / log(b); }