Warped Lines

Here is the more interesting part of the displacement function


function warp( dot, center, radius, strength )
{
    let dx = dot.x - center.x;
    let dy = dot.y - center.y;
    let delta = Math.sqrt( dx * dx + dy * dy );

    if( delta >= radius )
    {
        return dot;
    }

    let t = Math.max( 0, Math.min( (delta / radius), 1 ) );

    t = t * (2 - t);

    let ang = ( (1.0 - t) * strength ) + Math.atan2( dy, dx );

    const x = center.x + Math.cos( ang ) * delta;
    const y = center.y + Math.sin( ang ) * delta;

    return { x: x, y: y };
}