ratio = toReal(width()) / height();
function display(xa, ya)
max_x = xa[0];
max_y = ya[0];
min_x = xa[0];
min_y = ya[0];
for q = 1 to maxIndex(xa) do
max_x = max(xa[q], max_x);
max_y = max(ya[q], max_y);
min_x = min(xa[q], min_x);
min_y = min(ya[q], min_y);
done
diff_x = max_x - min_x;
diff_y = (max_y - min_y) * ratio;
diff = max(diff_x, diff_y)
if diff_x < diff_y then
offset_x = (1 - 1 / ratio) / 2;
offset_y = 0;
else
offset_x = 0;
offset_y = 0;
endif
for q = 1 to maxIndex(xa) do
x_from = (xa[q-1] - min_x) / diff + offset_x;
y_from = (ya[q-1] - min_y) / diff + offset_y;
x_to = (xa[q] - min_x) / diff + offset_x;
y_to = (ya[q] - min_y) / diff + offset_y;
line(width() * x_from, width() * y_from,
width() * x_to, width() * y_to);
done;
flush();
endfunc;
classic_x[0] = 0.0;
classic_y[0] = 0.0;
classic_x[1] = 0.33;
classic_y[1] = 0.0;
classic_x[2] = 0.5;
classic_y[2] = sqrt(3)/6.0;
classic_x[3] = 0.67;
classic_y[3] = 0.0;
classic_x[4] = 1.0;
classic_y[4] = 0.0;
square_x[0] = 0.0;
square_y[0] = 0.0;
square_x[1] = 0.33;
square_y[1] = 0.0;
square_x[2] = 0.33;
square_y[2] = 0.33;
square_x[3] = 0.67;
square_y[3] = 0.33;
square_x[4] = 0.67;
square_y[4] = 0.0;
square_x[5] = 1.0;
square_y[5] = 0.0;
subst_x = classic_x;
subst_y = classic_y;
line_x[0] = 0.0;
line_y[0] = 0.1;
line_x[1] = 1.0;
line_y[1] = 0.1;
triangle_x[0] = 0.0;
triangle_y[0] = 0.0;
triangle_x[1] = 0.5;
triangle_y[1] = 0.707;
triangle_x[2] = 1.0;
triangle_y[2] = triangle_y[0];
triangle_x[3] = triangle_x[0];
triangle_y[3] = triangle_y[0];
curr_x = triangle_x;
curr_y = triangle_y;
function substitute()
idx = 0;
for q = 1 to maxIndex(curr_x) do
local x0 = curr_x[q - 1];
local y0 = curr_y[q - 1];
local x1 = curr_x[q];
local y1 = curr_y[q];
local a = x1 - x0;
local b = y1 - y0;
for w = 0 to maxIndex(subst_x) do
local x = subst_x[w];
local y = subst_y[w];
local tmp_x[idx] = (a * x - b * y) + x0;
local tmp_y[idx] = (b * x + a * y) + y0;
idx = idx + 1;
done;
done;
curr_x = tmp_x;
curr_y = tmp_y;
endfunc;
autoFlush(FALSE);
display(curr_x, curr_y);
repeat 5 times
t = time();
substitute();
wait(1000 - (time() - t));
cls();
display(curr_x, curr_y);
done;