public override void DrawSelf(Graphics grfx) { var radius = (int)Point4.X - (int)Point2.X; var rect = new Rectangle((int)Point2.X, (int)Point2.Y, radius, radius); var secondCenter = new PointF(Point2.X + radius / 2F, Point2.Y + radius / 2F); using (Pen pen = new Pen(base.BorderColor)) using (SolidBrush brush = new SolidBrush(FillColor)) { grfx.TranslateTransform(secondCenter.X, secondCenter.Y); grfx.RotateTransform(this.RotationAngleInDegrees); grfx.TranslateTransform(-secondCenter.X, -secondCenter.Y); grfx.DrawEllipse(pen, rect); grfx.FillEllipse(brush, rect); grfx.ResetTransform(); //grfx.DrawRectangle(pen, new Rectangle(new Point((int)secondCenter.X, (int)secondCenter.Y), new Size(2, 2))); foreach (var rotationDegree in this.CenterToRadiusPoints) { var next = new PointF(secondCenter.X, secondCenter.Y - radius / 2F); var list = new List <PointF>() { secondCenter, next }; var radians = PolygonHlp.ConvertDegreesToRadians(rotationDegree); var rotatedPoints = PolygonHlp.RotatePolygon(list, secondCenter, radians + this.RotationAngleInRadians); grfx.DrawLine(pen, rotatedPoints[0], rotatedPoints[1]); } foreach (var tuple in this.RadiusToraduisPoints) { var next = new PointF(secondCenter.X, secondCenter.Y - radius / 2F); var list = new List <PointF>() { secondCenter, next }; var radians = PolygonHlp.ConvertDegreesToRadians(tuple.Item1); var rotatedPoints = PolygonHlp.RotatePolygon(list, secondCenter, radians + this.RotationAngleInRadians); var firstRersultPoint = rotatedPoints[1]; next = new PointF(secondCenter.X, secondCenter.Y - radius / 2F); list = new List <PointF>() { secondCenter, next }; radians = PolygonHlp.ConvertDegreesToRadians(tuple.Item2); rotatedPoints = PolygonHlp.RotatePolygon(list, secondCenter, radians + this.RotationAngleInRadians); var secondResultPoints = rotatedPoints[1]; grfx.DrawLine(pen, firstRersultPoint, secondResultPoints); } } }
public override void Enlarge() { var points = PolygonHlp.GetEnlargedPolygon(new List <PointF>() { this.Point1, this.Point2, this.Point3 }, -1F); this.Point1 = points[0]; this.Point2 = points[1]; this.Point3 = points[2]; }
public override bool Contains(PointF point) { var centroid = new PointF(this.АncillaryValues.Item1 + this.MinDimentionsDifference / 2f , this.АncillaryValues.Item2 + this.MinDimentionsDifference / 2f); point = PolygonHlp.RotatePoint(point, centroid, this.RotationAngleInRadians); var distance = DimentionCalculator.DistanceBetweenTwoPoints(centroid.X, centroid.Y, point.X, point.Y); var radius = this.MinDimentionsDifference / 2f; return(point.X > centroid.X && point.Y < centroid.Y && distance <= radius); }
public override void Shrink() { var points = PolygonHlp.GetEnlargedPolygon(new List <PointF>() { this.Point1, this.Point2, this.Point3, this.Point4 }, 1F); this.Point1 = points[0]; this.Point2 = points[1]; this.Point3 = points[2]; this.Point4 = points[3]; }
public override Shape NewShapeRotatedToRigth(float radians = GlobalConstants.RadiansRepresentationOfThirtyDegrees) { var listOfPoints = new List <PointF>() { this.Point1, this.Point2, this.Point3 }; var center = PolygonHlp.GetCentroidGeneric(new List <PointF>() { this.Point1, this.Point2, this.Point3 }); var rotatedPoints = PolygonHlp.RotatePolygon(listOfPoints, center, radians); return(new TriangleShape(rotatedPoints[0], rotatedPoints[1], rotatedPoints[2], this.BorderColor, base.FillColor)); }
public override Shape NewShapeRotatedToRigth(float radians = 0.5235988F) { var listOfPoints = new List <PointF>() { this.Point1, this.Point2 }; var center = PolygonHlp.GetCentroidGeneric(new List <PointF>() { this.Point1, this.Point2 }); var rotatedPoints = PolygonHlp.RotatePolygon(listOfPoints, center, radians); return(new LineShape(rotatedPoints[0], rotatedPoints[1], this.BorderColor, base.FillColor)); }
public override bool Contains(PointF point) { return(PolygonHlp.IsInPolygon(new PointF[] { this.Point1, this.Point2, this.Point3, this.Point4 }, point)); }