
    var dx = dx_from_linear(x, y)[0];
    var dy = dy_from_linear(x, y)[0];
    return len(dx, dy);
}

function grid_size_limited(x) {
    if(x < -grid_size)
        return -grid_size;
    if(x > +grid_size)
        return +grid_size;
    return x;
}

function dx(x, y) {
    return dxy(x, y)[0];
}

function dy(x, y) {
    return dxy(x, y)[1];
}


function gsx(x, y) {
    return grid_size_limited(dx(x, y) * (0.5 - dy_from_linear(x, y)[0]) * grid_size * shiftd);
}

function gsy(x, y) {
    return grid_size_l