/************************************************************ * GRAPHICS FUNCTIONS FOR THE DIVIDE AND CONQUER ALGORITHM * ************************************************************/ public void drawDQStrip(PointSet S, Point M) { Graphics g = Panel1.CreateGraphics(); int x, w; // set x if ((M.x - S.dmin) < S.first().x) { x = S.first().x; } else { x = M.x - ((int)S.dmin); } // set w if ((M.x + S.dmin) > S.last().x) { w = S.last().x - x; } else { w = M.x + ((int)S.dmin) - x; } SolidBrush brush = new SolidBrush(Color.Pink); g.FillRectangle(brush, x, 0, w, Y_MAX); drawVertical(M, Color.Blue); drawPoints(S, Color.Black); }
public void eraseField(PointSet S) { Graphics g = Panel1.CreateGraphics(); int w, x; x = S.first().x; w = S.last().x - x; SolidBrush brush = new SolidBrush(Color.White); g.FillRectangle(brush, x, 0, w, Y_MAX); drawPoints(S, Color.Black); }
public void drawDQBoundingBox(PointSet S, Point P, Point M, Boolean lookR) { Graphics g = Panel1.CreateGraphics(); int x, y, w, h; // set x if (lookR == true) { x = P.x; } else { if ((P.x - S.dmin) < S.first().x) { x = S.first().x; } else { x = P.x - ((int)S.dmin); } } // set y if ((P.y - S.dmin) < 0) { y = 0; } else { y = P.y - ((int)S.dmin); } // set w if (lookR == true) { if ((x + S.dmin) > S.last().x) { w = S.last().x - x; } else { w = ((int)S.dmin); } } else { w = P.x - x; } // set h if ((P.y + S.dmin) > Y_MAX) { h = Y_MAX - y; } else { h = P.y + ((int)S.dmin) - y; } SolidBrush brush = new SolidBrush(Color.Yellow); g.FillRectangle(brush, x, y, w, h); drawVertical(M, Color.Blue); drawPoints(S, Color.Black); }