All pastes #51377 Raw Edit

Miscellany

public text v1 · immutable
#51377 ·published 2006-04-26 03:05 UTC
rendered paste body
    const eRectangle &bounds = eWallRim::GetBounds();
    double lx = bounds.GetLow().x - border, hx = bounds.GetHigh().x + border;
    double ly = bounds.GetLow().y - border, hy = bounds.GetHigh().y + border;
    double mw = hx - lx, mh = hy - ly;
    double xpos, ypos, xscale, yscale;
    double xrat = (rw * mh) / (rh * mw);
    double yrat = (rh * mw) / (rw * mh);
    if(xrat > yrat) {
        xscale = (w * rh) / (mh * rw);
        yscale = h / mh;
        xpos = x + ix * (w - w * yrat);
        ypos = y;
    } else {
        xscale = w / mw;
        yscale = (h * rw) / (mw * rh);
        xpos = x;
        ypos = y + iy * (h - h * xrat);
    }
    xpos -= lx * xscale;
    ypos -= ly * yscale;