/// <summary> /// Draw the point if it is inside the border rectangle /// </summary> public override void Draw(GlRectangle Border) { if (Border == null || !Border.isPointInside(this)) { return; } this.Draw(); }
private void DrawPoints(GlRectangle Border, int GlDrawMode) { if (Border == null || !ActivateDrawStart()) { return; } ActivateDrawing(); bool isInside = Border.isPointInside(this[0]); GlPolygon ToDraw = new GlPolygon(this.Center); if (Border.isPointInside(this[this.CountOfPoints - 1]) != isInside) { if (!isInside) { ToDraw.AddVertex(this[this.CountOfPoints - 1]); } GlPointR2[] I = new GlLineR2(this[0], new GlVectorR2(this[0].X - this[this.CountOfPoints - 1].X, this[0].Y - this[this.CountOfPoints - 1].Y)).getIntersection(Border); if (I.Length == 2) { ToDraw.AddVertex(new GlLineSegment(this[this.CountOfPoints - 1], this[0]).isPointBelongs(I[0]) ? I[0] : I[1]); } else if (I.Length == 1 && new GlLineSegment(this[this.CountOfPoints - 1], this[0]).isPointBelongs(I[0])) { ToDraw.AddVertex(I[0]); } } for (int i = 0; i < this.CountOfPoints - 1; i++) { if (isInside) { ToDraw.AddVertex(this[i]); } if (Border.isPointInside(this[i + 1]) != isInside) { GlPointR2[] I = new GlLineR2(this[i], new GlVectorR2(this[i + 1].X - this[i].X, this[i + 1].Y - this[i].Y)).getIntersection(Border); if (I.Length == 2) { ToDraw.AddVertex(new GlLineSegment(this[i], this[i + 1]).isPointBelongs(I[0]) ? I[0] : I[1]); } else if (I.Length == 1 && new GlLineSegment(this[i], this[i + 1]).isPointBelongs(I[0])) { ToDraw.AddVertex(I[0]); } isInside = !isInside; } } Gl.glBegin(GlDrawMode); for (int i = 0; i < ToDraw.CountOfPoints; i++) { if (ToDraw[i] != null) { Gl.glVertex2f(ToDraw[i].X, ToDraw[i].Y); } } Gl.glEnd(); ActivateDrawed(); }