/// <summary>Converts the current instance to a highly-precise Cartesian coordinate.</summary> public PointD ToCartesianPointD() { // First, convert to the North/CW orientation PolarCoordinate AdjustedValue = ToOrientation(Azimuth.East, PolarCoordinateOrientation.Counterclockwise); // Now convert to pixel (same as Cartesian but -Y) return(new PointD(R * Math.Cos(AdjustedValue.Theta.ToRadians().Value), (R * Math.Sin(AdjustedValue.Theta.ToRadians().Value)))); }
/// <summary>Draws a closed shape.</summary> public void DrawPolygon(Pen pen, PolarCoordinate[] points) { #if PocketPC //gx.DrawPolygon(new PenX(pen.Color, pen.Width), ToPointArray(points)); g.DrawPolygon(pen, ToPointArray(points)); #else g.DrawPolygon(pen, ToPointFArray(points)); // GraphicsPath Path = new GraphicsPath(); // Path.AddLines(ToPointFArray(points)); // g.DrawPath(pen, Path); // Path.Dispose(); #endif }
/// <summary>Fills and outlines a polygon using the specified style.</summary> public void DrawAndFillPolygon(Pen pen, Brush brush, PolarCoordinate[] points) { #if PocketPC Point[] ConvertedPoints = ToPointArray(points); #else PointF[] ConvertedPoints = ToPointFArray(points); #endif if(brush != null) g.FillPolygon(brush, ConvertedPoints); if(pen != null) g.DrawPolygon(pen, ConvertedPoints); }
/// <summary> /// Converts an array of polar coordinates into a <strong>GraphicsPath</strong> /// object. /// </summary> public GraphicsPath ToGraphicsPath(PolarCoordinate[] points) { GraphicsPath path = new GraphicsPath(); path.AddLines(ToPointFArray(points)); return path; }
/// <summary>Converts a polar coordinate to a pixel coordinate.</summary> public Point ToPoint(PolarCoordinate coordinate) { PointD point = ToPointD(coordinate); return new Point((int)point.X, (int)point.Y); }
public void DrawCurve(Pen pen, PolarCoordinate[] points) { g.DrawCurve(pen, ToPointFArray(points)); }
/// <summary>Draws multiple rounded lines that travels through several points.</summary> public void DrawBeziers(Pen pen, PolarCoordinate[] points) { g.DrawBeziers(pen, ToPointFArray(points)); }
/// <summary>Draws a rounded line.</summary> public void DrawArc(Pen pen, PolarCoordinate pt1, PolarCoordinate pt2) { // Calculate pixel coordinates PointF Start = ToPointF(pt1); PointF End = ToPointF(pt2); SizeF size = new SizeF(End.X - Start.X, End.Y - Start.Y); // Now draw the arc g.DrawArc(pen, new RectangleF(Start, size), (float)pt1.Theta, (float)pt2.Theta); }
public void DrawCenteredString(string s, Font font, Brush brush, PolarCoordinate point, StringFormat format) { PointD StartPoint = ToPointD(point); SizeF StringSize = g.MeasureString(s, font); PointD NewStart = new PointD(StartPoint.X - StringSize.Width * 0.5, StartPoint.Y - StringSize.Height * 0.5); g.DrawString(s, font, brush, ToPointF(NewStart), format); }
public void DrawString(string s, Font font, SolidBrush brush, PolarCoordinate point) { PointD Location = ToPointD(point); #if PocketPC g.DrawString(s, font, brush, new RectangleF((float)Location.X, (float)Location.Y, 240.0f, 320.0f)); #else g.DrawString(s, font, brush, ToPointF(Location)); #endif }
public void DrawString(string s, Font font, Brush brush, PolarCoordinate point, StringFormat format) { g.DrawString(s, font, brush, ToPointF(point), format); }
/// <summary>Draws a single straight line.</summary> public void DrawLine(Pen pen, PolarCoordinate pt1, PolarCoordinate pt2) { #if PocketPC // Convert to pixel coordinates PointD start = ToPointD(pt1); PointD end = ToPointD(pt2); //gx.DrawLine(new PenX(pen.Color, pen.Width), (float)start.X, (float)start.Y, (float)end.X, (float)end.Y); g.DrawLine(pen, (int)start.X, (int)start.Y, (int)end.X, (int)end.Y); #else // Convert to pixel coordinates g.DrawLine(pen, ToPointF(pt1), ToPointF(pt2)); #endif }
/// <summary>Converts a polar coordinate to a precise pixel coordinate.</summary> public PointF ToPointF(PolarCoordinate coordinate) { return ToPointF(ToPointD(coordinate)); //fixes problems with DrawRotatedString }
/// <summary>Converts the current instance into a polar coordinate.</summary> private PolarCoordinate PointDToPolarCoordinate(PointD value) { // double Value; // double TempY = -pY; // if(pX == 0) // Value = 0; // else // Value = TempY / pX; // Calculate the coordinate using the default: 0° = East // and counter-clockwise movement Radian Result = new Radian(Math.Atan2(-value.Y, value.X)); PolarCoordinate Result2 = new PolarCoordinate((float)Math.Sqrt(value.X * value.X + value.Y * value.Y), Result.ToAngle(), Azimuth.East, PolarCoordinateOrientation.Counterclockwise); // And re-orient it at North and Clockwise return Result2.ToOrientation(Azimuth.North, PolarCoordinateOrientation.Clockwise); }
/// <summary>Converts a polar coordinate to a highly-precise pixel coordinate.</summary> public PointD ToPointD(PolarCoordinate coordinate) { return coordinate.ToOrientation(pOrigin, pOrientation).Rotate(-pRotation.DecimalDegrees).ToPointD() .Multiply(HorizontalScale, VerticalScale).Add(HalfWidth, HalfHeight); }
/// <summary>Draws text rotated by the specified amount.</summary> public void DrawRotatedString(string s, Font font, Brush brush, PolarCoordinate point) { PointF h = ToPointF(point); g.RotateTransform(Convert.ToSingle(point.Theta.DecimalDegrees + pOrigin.DecimalDegrees - pRotation.DecimalDegrees), MatrixOrder.Append); g.TranslateTransform(h.X, h.Y, MatrixOrder.Append); g.DrawString(s, font, brush, PointF.Empty, pStringFormat); g.ResetTransform(); }
/// <summary> /// Converts an array of polar coordinates to an array of highly-precise pixel /// coordinates. /// </summary> public PointD[] ToPointDArray(PolarCoordinate[] points) { // Convert to an array of PointF objects //int Count = points.Length; PointD[] Result = new PointD[points.Length]; for(int index = 0; index < points.Length; index++) Result[index] = ToPointD(points[index]); return Result; }
public void DrawCenteredString(string s, Font font, SolidBrush brush, PolarCoordinate point) { PointD StartPoint = ToPointD(point); SizeF StringSize = g.MeasureString(s, font); PointD NewStart = new PointD(StartPoint.X - StringSize.Width * 0.5, StartPoint.Y - StringSize.Height * 0.5); #if PocketPC g.DrawString(s, font, brush, (float)NewStart.X, (float)NewStart.Y); //, StringSize.Width, StringSize.Height)); #else g.DrawString(s, font, brush, ToPointF(NewStart)); #endif }
/// <summary>Draws a rounded line that travels through several points.</summary> public void DrawBezier(Pen pen, PolarCoordinate pt1, PolarCoordinate pt2, PolarCoordinate pt3, PolarCoordinate pt4) { g.DrawBezier(pen, ToPointF(pt1), ToPointF(pt2), ToPointF(pt3), ToPointF(pt4)); }
/// <summary>Draws a square or rectangular shape.</summary> public void DrawRectangle(Pen pen, PolarCoordinate upperLeft, PolarCoordinate lowerRight) { PointD UL = ToPointD(upperLeft); PointD LR = ToPointD(lowerRight); #if PocketPC g.DrawRectangle(pen, (int)UL.X, (int)UL.Y, (int)Math.Abs(LR.X - UL.X), (int)Math.Abs(LR.Y - UL.Y)); #else g.DrawRectangle(pen, (float)UL.X, (float)UL.Y, (float)Math.Abs(LR.X - UL.X), (float)Math.Abs(LR.Y - UL.Y)); #endif }
public void DrawClosedCurve(Pen pen, PolarCoordinate[] points, float tension, FillMode fillMode) { g.DrawClosedCurve(pen, ToPointFArray(points), tension, fillMode); }
/// <summary>Draws a circular shape.</summary> public void DrawEllipse(Pen pen, PolarCoordinate center, float radius) { // Translate the coordinate to the center PointD CenterPoint = ToPointD(center); PointD ControlCenterPoint = ToPointD(PolarCoordinate.Empty); // Calculate the bounding box for the ellipse double minX = ControlCenterPoint.X; double minY = ControlCenterPoint.Y; double maxX = ControlCenterPoint.X; double maxY = ControlCenterPoint.Y; for(int angle = 0; angle < 360; angle += 10) { PointD x = ToPointD(new PolarCoordinate(radius, new Angle(angle), Azimuth.North, PolarCoordinateOrientation.Clockwise)); minX = Math.Min(minX, x.X); minY = Math.Min(minY, x.Y); maxX = Math.Max(maxX, x.X); maxY = Math.Max(maxY, x.Y); } // Now translate the values by the center point double width = Math.Abs(maxX - minX); double height = Math.Abs(maxY - minY); #if PocketPC // gx.DrawEllipse(new PenX(pen.Color, pen.Width), // (float)(CenterPoint.X - (width * 0.5)), (float)(CenterPoint.Y - (height * 0.5)), (float)width, (float)height); g.DrawEllipse(pen, (int)(CenterPoint.X - (width * 0.5)), (int)(CenterPoint.Y - (height * 0.5)), (int)width, (int)height); #else g.DrawEllipse(pen, (float)(CenterPoint.X - (width * 0.5)), (float)(CenterPoint.Y - (height * 0.5)), (float)width, (float)height); #endif }
public void DrawCurve(Pen pen, PolarCoordinate[] points, int offset, int numberOfSegments, float tension) { g.DrawCurve(pen, ToPointFArray(points), offset, numberOfSegments, tension); }
/// <summary>Fills the interior of a closed shape.</summary> public void FillPolygon(Brush brush, PolarCoordinate[] points) { #if PocketPC //gx.FillPolygon(new SolidBrushX(brush.Color), ToPointArray(points)); g.FillPolygon(brush, ToPointArray(points)); #else g.FillPolygon(brush, ToPointFArray(points)); #endif }