static void GLUT_Paint( DaoProcess *proc, DaoValue *p[], int N ) { GLUT_SetGraphics( proc, p, N ); DaoxCanvas_SetViewport( daox_current_canvas, -window_width/2, window_width/2, -window_height/2, window_height/2 ); glutMainLoop(); }
void DaoxCanvas_Move( int x, int y ) { DaoxAABBox2D box = daox_current_canvas->viewport; float xscale = (box.right - box.left) / window_width; float yscale = (box.top - box.bottom) / window_height; box.left -= (x - last_x) * xscale; box.right -= (x - last_x) * xscale; box.bottom += (y - last_y) * xscale; box.top += (y - last_y) * xscale; last_x = x; last_y = y; if( box.left > 0.9*window_width ) return; if( box.right < 0.1*window_width ) return; if( box.bottom > 0.9*window_height ) return; if( box.top < 0.1*window_height ) return; DaoxCanvas_SetViewport( daox_current_canvas, box.left, box.right, box.bottom, box.top ); }
void DaoxWindow_MoveCanvas( DaoxWindow *self, DaoxCanvas *canvas, int x, int y ) { DaoxAABBox2D box = canvas->viewport; float xscale = (box.right - box.left) / self->width; float yscale = (box.top - box.bottom) / self->height; int dx = x - self->cursorPosX; int dy = y - self->cursorPosY; box.left -= dx * xscale; box.right -= dx * xscale; box.bottom += dy * yscale; box.top += dy * yscale; // TODO: Use canvas bounding box to do it; //if( box.left > 0.9*self->width ) return; //if( box.right < 0.1*self->width ) return; //if( box.bottom > 0.9*self->height ) return; //if( box.top < 0.1*self->height ) return; DaoxCanvas_SetViewport( canvas, box.left, box.right, box.bottom, box.top ); }
void DaoxCanvas_Zoom( int zoomin ) { DaoxAABBox2D box = daox_current_canvas->viewport; float width, height, dw, dh; width = box.right - box.left; height = box.top - box.bottom; dw = 0.0; dh = 0.0; if( zoomin ){ dw = width / 6; dh = height / 6; }else{ dw = - width / 4; dh = - height / 4; } box.left += dw; box.right -= dw; box.bottom += dh; box.top -= dh; DaoxCanvas_SetViewport( daox_current_canvas, box.left, box.right, box.bottom, box.top ); }