示例#1
0
void Viewport::Adjust (Perspective& np) {
    long x = np.curx;
    long y = np.cury;
    AlignHelper(align, x, y, np.curwidth, np.curheight);

    float px = float(x - np.x0) / float(np.width);
    float py = float(y - np.y0) / float(np.height);
    float zx = (
        float(np.width) / float(cwidth) *
        float(perspective->curwidth) / float(np.curwidth)
    );
    float zy = (
        float(np.height) / float(cheight) *
        float(perspective->curheight) / float(np.curheight)
    );
    DoAdjust(px, py, zx, zy);
    np = *perspective;
}
示例#2
0
void Viewport::DoAdjust (float px, float py, float zx, float zy) {
    register Perspective* p = perspective;
    register Shape* s = component->GetShape();
    cwidth = s->width;
    cheight = s->height;

    if (px < 0.0) px = 0.0;
    if (px > 1.0) px = 1.0;
    if (py < 0.0) py = 0.0;
    if (py > 1.0) py = 1.0;

    long w = round(cwidth * zx);
    long h = round(cheight * zy);
    long x = round(w * px);
    long y = round(h * py);

    AlignHelper(align, x, y, -p->curwidth, -p->curheight);
    Place(component, -x, -y, -x + (w - 1), -y + (h - 1));
    p->width = w;
    p->height = h;
    p->curx = p->x0 + x;
    p->cury = p->y0 + y;
    p->Update();
}
示例#3
0
void Viewport::DoAdjust(float px, float py, float zx, float zy) {
    register Perspective* p = perspective;
    register Shape* s = interior()->GetShape();
    cwidth = s->width;
    cheight = s->height;

    if (px < 0.0) px = 0.0;
    if (px > 1.0) px = 1.0;
    if (py < 0.0) py = 0.0;
    if (py > 1.0) py = 1.0;

    int w = Math::round(cwidth * zx);
    int h = Math::round(cheight * zy);
    int x = Math::round(w * px);
    int y = Math::round(h * py);

    AlignHelper(align, x, y, -p->curwidth, -p->curheight);
    Place(interior(), -x, -y, -x + (w - 1), -y + (h - 1));
    p->width = w;
    p->height = h;
    p->curx = p->x0 + x;
    p->cury = p->y0 + y;
    p->Update();
}
示例#4
0
float Viewport::YPos () {
    long x = 0;
    long y = perspective->cury;
    AlignHelper(align, x, y, perspective->curwidth, perspective->curheight);
    return float(y - perspective->y0) / float(perspective->height);
}
示例#5
0
float Viewport::XPos () {
    long x = perspective->curx;
    long y = 0;
    AlignHelper(align, x, y, perspective->curwidth, perspective->curheight);
    return float(x - perspective->x0) / float(perspective->width);
}