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; }
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(); }
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(); }
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); }
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); }