/// <summary> /// Demonstrates the use of XGraphics.DrawBeziers. /// </summary> public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); int n = 2; int count = 1 + 3 * n; XPoint[] points = new XPoint[count]; Random rnd = new Random(42); for (int idx = 0; idx < count; idx++) { points[idx].X = 20 + rnd.Next(600); points[idx].Y = 50 + rnd.Next(800); } // Draw the points XPen pen = new XPen(XColors.Red, 0.5); pen.DashStyle = XDashStyle.Dash; for (int idx = 0; idx + 3 < count; idx += 3) { gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx])); gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 1])); gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 2])); gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 3])); gfx.DrawLine(pen, points[idx], points[idx + 1]); gfx.DrawLine(pen, points[idx + 2], points[idx + 3]); } // Draw the curve gfx.DrawBeziers(properties.Pen2.Pen, points); }
public static void DrawEllipse(XGraphics gfx, int number) { // BeginBox(gfx, number, "DrawEllipse"); XPen pen = new XPen(XColors.DarkBlue, 2.5); gfx.DrawEllipse(pen, 10, 0, 100, 60); gfx.DrawEllipse(XBrushes.Goldenrod, 130, 0, 100, 60); gfx.DrawEllipse(pen, XBrushes.Goldenrod, 10, 80, 100, 60); gfx.DrawEllipse(pen, XBrushes.Goldenrod, 150, 80, 60, 60); EndBox(gfx); }
/// <summary> /// Demonstrates the use of XGraphics.DrawRoundedRectangle. /// </summary> public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); // Stroke ellipse gfx.DrawEllipse(properties.Pen1.Pen, 50, 100, 450, 150); // Fill ellipse gfx.DrawEllipse(properties.Brush2.Brush, new Rectangle(50, 300, 450, 150)); // Stroke and fill ellipse gfx.DrawEllipse(properties.Pen2.Pen, properties.Brush2.Brush, new RectangleF(50, 500, 450, 150)); // Stroke circle gfx.DrawEllipse(properties.Pen2.Pen, new XRect(100, 200, 400, 400)); #if DEBUG int count = 360; XPoint[] circle = new XPoint[count]; for (int idx = 0; idx < count; idx++) { double rad = idx * 2 * Math.PI / count; circle[idx].X = Math.Cos(rad) * 200 + 300; circle[idx].Y = Math.Sin(rad) * 200 + 400; } gfx.DrawPolygon(properties.Pen3.Pen, circle); #endif }
/// <summary> /// Demonstrates the use of XGraphics.SetClip. /// </summary> public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); gfx.Save(); gfx.TranslateTransform(50, 50); gfx.IntersectClip(new Rectangle(0, 0, 400, 250)); gfx.TranslateTransform(50, 50); //gfx.Clear(XColor.GhostWhite); gfx.DrawEllipse(XPens.Green, XBrushes.Yellow, 40, 40, 500, 500); gfx.Restore(); gfx.Save(); //gfx.Transform = new XMatrix(); //XMatrix.Identity; gfx.TranslateTransform(200, 200); gfx.IntersectClip(new Rectangle(0, 0, 400, 250)); gfx.DrawEllipse(XPens.Green, XBrushes.Yellow, 40, 40, 500, 500); gfx.Restore(); }
/// <summary> /// Demonstrates the use of XGraphics.DrawBezier. /// </summary> public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); gfx.DrawEllipse(XBrushes.Red, MakeRect(50, 100)); gfx.DrawEllipse(XBrushes.Red, MakeRect(450, 100)); gfx.DrawEllipse(XBrushes.Red, MakeRect(550, 190)); gfx.DrawEllipse(XBrushes.Red, MakeRect(150, 300)); gfx.DrawLine(XPens.Red, 50, 100, 450, 100); gfx.DrawLine(XPens.Red, 550, 190, 150, 300); gfx.DrawBezier(properties.Pen2.Pen, 50, 100, 450, 100, 550, 190, 150, 300); //XPoint[] points = new XPoint[1 + 3 * 3]; //Random rnd = new Random(); //for (int idx = 0; idx < points.Length; idx++) //{ // points[idx].X = 100 + rnd.Next(400); // points[idx].Y = 200 + rnd.Next(700); //} //gfx.DrawBeziers(properties.Pen1.Pen, points); }
/// <summary> /// Source and more infos: http://www.math.dartmouth.edu/~dlittle/java/SpiroGraph/ /// </summary> public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); //int R = 60, r = 60, p = 60, N = 270; // Cardioid //int R = 60, r = -45, p = -101, N = 270; // Rounded Square //int R = 75, r = -25, p = 85, N = 270; // Gold fish //int R = 75, r = -30, p = 60, N = 270; // Star fish //int R = 100, r = 49, p = 66, N = 7; // String of Pearls //int R = 90, r = 1, p = 105, N = 105; // Rotating Triangle //int R = 90, r = 1, p = 105, N = 105; int R = 60, r = 2, p = 122, N = 490; int revs = Math.Abs(r) / Gcd(R, Math.Abs(r)); XPoint[] points = new XPoint[revs * N + 1]; for (int i = 0; i <= revs * N; i++) { double t = 4 * i * Math.PI / N; points[i].X = ((R+r)*Math.Cos(t) - p * Math.Cos((R+r)* t / r)); points[i].Y = ((R+r)*Math.Sin(t) - p * Math.Sin((R+r)* t / r)); } #if true // Draw as lines gfx.TranslateTransform(300, 250); gfx.DrawLines(properties.Pen2.Pen, points); //gfx.DrawPolygon(properties.Pen2.Pen, properties.Brush2.Brush, points, properties.General.FillMode); // Draw as closed curve gfx.TranslateTransform(0, 400); gfx.DrawClosedCurve(properties.Pen2.Pen, properties.Brush2.Brush, points, properties.General.FillMode, properties.General.Tension); #else gfx.TranslateTransform(300, 400); XSolidBrush dotBrush = new XSolidBrush(properties.Pen2.Pen.Color); float width = properties.Pen2.Width; for (int i = 0; i < revs * N; i++) gfx.DrawEllipse(dotBrush,points[i].X, points[i].Y, width, width); #endif }
/// <summary> /// /// </summary> /// <param name="gfx"></param> /// <param name="brush"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="rect"></param> private static void DrawEllipseInternal( XGraphics gfx, XSolidBrush brush, XPen pen, bool isStroked, bool isFilled, ref XRect rect) { if (isStroked && isFilled) { gfx.DrawEllipse(pen, brush, rect); } else if (isStroked && !isFilled) { gfx.DrawEllipse(pen, rect); } else if (!isStroked && isFilled) { gfx.DrawEllipse(brush, rect); } }
public void Paint(XGraphics graphics, RectangleF rect, MapOptions options, Color dotColor, XBrush labelBrush, XFont labelFont) { if (graphics == null) throw new ArgumentNullException("graphics"); Point pt = Astrometrics.LocationToCoordinates(Location); using (RenderUtil.SaveState(graphics)) { graphics.SmoothingMode = XSmoothingMode.HighSpeed; graphics.TranslateTransform(pt.X, pt.Y); graphics.ScaleTransform(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY); const float radius = 3; XBrush brush = new XSolidBrush(dotColor); XPen pen = new XPen(dotColor); graphics.DrawEllipse(brush, -radius / 2, -radius / 2, radius, radius); graphics.SmoothingMode = XSmoothingMode.HighQuality; graphics.DrawEllipse(pen, -radius / 2, -radius / 2, radius, radius); XStringFormat format = (LabelBiasX == -1) ? RenderUtil.StringFormatTopRight : (LabelBiasX == 1) ? RenderUtil.StringFormatTopLeft : RenderUtil.StringFormatTopCenter; XSize size = graphics.MeasureString(Name, labelFont); XPoint pos = new XPoint(0, 0); //pos.X += ( LabelBiasX * radius / 2 ) + ( -size.Width * ( 1 - LabelBiasX ) / 2.0f ); pos.Y += (LabelBiasY * radius / 2) + (-size.Height * (1 - LabelBiasY) / 2.0f); pos.X += (LabelBiasX * radius / 2); //pos.Y += ( LabelBiasY * radius / 2 ); graphics.DrawString(Name, labelFont, labelBrush, pos.X, pos.Y, format); } }
void DrawSecondHand(XGraphics gfx, XPen pen) { XGraphicsState gs = gfx.Save(); gfx.RotateTransform(360 * Time.Second / 60 + 6 * Time.Millisecond / 1000); gfx.DrawEllipse(new XSolidBrush(pen.Color), -15, -15, 30, 30); gfx.DrawLine(pen, 0, 40, 0, -800); gfx.Restore(gs); }
static void DrawFace(XGraphics gfx, XPen pen, XBrush brush) { for (int i = 0; i < 60; i++) { int size = i % 5 == 0 ? 100 : 30; gfx.DrawEllipse(pen, brush, 0 - size / 2, -900 - size / 2, size, size); gfx.RotateTransform(6); } }
/// <summary> /// Draws the number in the middle of the page. /// </summary> static void DrawNumber(XGraphics gfx, XFont font, int number) { const double width = 130; gfx.DrawEllipse(new XPen(XColors.DarkBlue, 7), XBrushes.DarkOrange, new XRect((gfx.PageSize.Width - width) / 2, (gfx.PageSize.Height - width) / 2, width, width)); gfx.DrawString(number.ToString(), font, XBrushes.Firebrick, new XRect(new XPoint(), gfx.PageSize), XStringFormats.Center); }
private void DrawEllipse(XGraphics gfx, IEllipse ellipse) { double x = Math.Min(ellipse.Point1.X, ellipse.Point2.X); double y = Math.Min(ellipse.Point1.Y, ellipse.Point2.Y); double width = Math.Abs(ellipse.Point2.X - ellipse.Point1.X); double height = Math.Abs(ellipse.Point2.Y - ellipse.Point1.Y); if (ellipse.Fill.A > 0x00) { var pen = new XPen( ToXColor(ellipse.Stroke), X(ellipse.StrokeThickness)); var brush = new XSolidBrush(ToXColor(ellipse.Fill)); gfx.DrawEllipse( pen, brush, X(x), Y(y), X(width), Y(height)); } else { var pen = new XPen( ToXColor(ellipse.Stroke), X(ellipse.StrokeThickness)); gfx.DrawEllipse( pen, X(x), Y(y), X(width), Y(height)); } }
private static void DrawVertex(XGraphics g, string v, LayoutProvider layout, NetworkColorizer colorizer) { OpenTK.Vector3 p = layout.GetPositionOfNode(v); double size = Renderer.ComputeNodeSize(v); if (!double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsNaN(p.Z)) g.DrawEllipse(new SolidBrush(colorizer[v]), p.X - size / 2d - x_offset, p.Y - size / 2d - y_offset, size, size); }
public override void PaintPdf(PdfSharp.Drawing.XGraphics g2D, int pageNo, PointF pageStart, Ctx ctx, bool isView) { if (m_item == null) { return; } // //System.Drawing.SolidBrush g2Dpen = new System.Drawing.SolidBrush(m_color); XSolidBrush g2Dpen = new XSolidBrush(XColor.FromArgb(m_color)); XPen pen = new XPen(XColor.FromArgb(m_color)); pen.DashStyle = PdfSharp.Drawing.XDashStyle.Solid; // PointF location = GetAbsoluteLocation(pageStart); int x = (int)location.X; int y = (int)location.Y; int width = m_item.GetMaxWidth(); int height = m_item.GetMaxHeight(); if (m_item.GetPrintFormatType().Equals(MPrintFormatItem.PRINTFORMATTYPE_Line)) { g2D.DrawLine(pen, (double)x, (double)y, (double)x + width, (double)y + height); } else { String type = m_item.GetShapeType(); if (type == null) { type = ""; } if (m_item.IsFilledRectangle()) { if (type.Equals(MPrintFormatItem.SHAPETYPE_3DRectangle)) { g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height); } else if (type.Equals(MPrintFormatItem.SHAPETYPE_Oval)) { g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height); } else if (type.Equals(MPrintFormatItem.SHAPETYPE_RoundRectangle)) { g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height); //, m_item.getArcDiameter(), m_item.getArcDiameter()); } else { g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height); } } else { if (type.Equals(MPrintFormatItem.SHAPETYPE_3DRectangle)) { g2D.DrawRectangle(pen, (double)x, (double)y, (double)width, (double)height); } else if (type.Equals(MPrintFormatItem.SHAPETYPE_Oval)) { g2D.DrawEllipse(pen, (double)x, (double)y, (double)width, (double)height); } else if (type.Equals(MPrintFormatItem.SHAPETYPE_RoundRectangle)) { g2D.DrawRectangle(pen, (double)x, (double)y, (double)width, (double)height); //, m_item.getArcDiameter(), m_item.getArcDiameter()); } else { g2D.DrawRectangle(pen, (double)x, (double)y, (double)width, (double)height); } //PrintElement } } }
public static void DrawHandle(Canvas canvas, XGraphics graphics, Palette palette, Rect bounds, DrawingContext context, bool alwaysAlpha, bool round) { if (bounds.Width <= 0 || bounds.Height <= 0) { return; } using (var quality = new Smoothing(graphics, XSmoothingMode.Default)) { XBrush brush; Pen pen; var alpha = 180; if (context.Selected) { if (!alwaysAlpha) { alpha = 255; } brush = palette.Gradient(bounds, Color.FromArgb(alpha, Color.LemonChiffon), Color.FromArgb(alpha, Color.DarkOrange)); pen = palette.Pen(Color.FromArgb(alpha, Color.Chocolate), 0); } else { brush = palette.Gradient(bounds, Color.FromArgb(alpha, Color.LightCyan), Color.FromArgb(alpha, Color.SteelBlue)); pen = palette.Pen(Color.FromArgb(alpha, Color.Navy), 0); } if (round) { graphics.DrawEllipse(brush, bounds.ToRectangleF()); graphics.DrawEllipse(pen, bounds.ToRectangleF()); } else { graphics.DrawRectangle(brush, bounds.ToRectangleF()); graphics.DrawRectangle(pen, bounds.ToRectangleF()); } } }
private static void DrawVertex(XGraphics g, Vertex v, LayoutProvider layout, NetworkColorizer colorizer) { Vector3 p = layout.GetPositionOfNode(v); double size = ComputeNodeSize(v); if (!double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsNaN(p.Z)) g.DrawEllipse(new SolidBrush(colorizer[v]), p.X - size/2d, p.Y - size/2d, size, size); }
private static void DrawVertex(XGraphics g, Vertex v, LayoutProvider layout, NetworkColorizer colorizer) { Vector3 p = layout.GetPositionOfNode(v); double size = Math.Min(2f, Math.Max(0.05d, Math.Log10(v.Degree))); if (!double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsNaN(p.Z)) g.DrawEllipse(new SolidBrush(colorizer[v]), p.X - size/2d, p.Y - size/2d, size, size); }
void DrawFigures(XGraphics gfx, double W, double H) { /* COWARD'S TRIANGLE */ XPen pen = new XPen(XColors.Black, 1); pen.LineJoin = XLineJoin.Round; XFont T10R = new XFont("Times New Roman", 10, XFontStyle.Regular); XTextFormatter tf = new XTextFormatter(gfx); tf.Alignment = XParagraphAlignment.Center; //Triangles XPoint[] polygon = new XPoint[] { new XPoint(84, 550), new XPoint(84, 685), new XPoint(284, 685) }; gfx.DrawPolygon(pen, XBrushes.Green, polygon, XFillMode.Alternate); polygon = new XPoint[] { new XPoint(Hx, Hy), new XPoint(Nx, Ny), new XPoint(Fx, Fy), new XPoint(284, 685) }; gfx.DrawPolygon(pen, XBrushes.Yellow, polygon, XFillMode.Alternate); polygon = new XPoint[] { new XPoint(84, 550), new XPoint(Nx, Ny), new XPoint(Lx, Ly) }; gfx.DrawPolygon(pen, XBrushes.DarkOrange, polygon, XFillMode.Alternate); polygon = new XPoint[] { new XPoint(Hx, Hy), new XPoint(Nx, Ny), new XPoint(Lx, Ly) }; gfx.DrawPolygon(pen, XBrushes.Red, polygon, XFillMode.Alternate); //Point gfx.DrawEllipse(pen, XBrushes.White, Cx, Cy, 6, 6); //Texts XRect rect = new XRect(72, 550, 10, 10); tf.DrawString("21", T10R, XBrushes.Red, rect); rect = new XRect(72, 687, 10, 10); tf.DrawString("0", T10R, XBrushes.Red, rect); rect = new XRect(150, 687, 50, 10); tf.DrawString("Methane %", T10R, XBrushes.Red, rect); rect = new XRect(270, 687, 15, 10); tf.DrawString("100", T10R, XBrushes.Red, rect); /* ELLICOTT DIAGRAM */ rect = new XRect(297, 550, 112, 75); gfx.DrawRectangle(XPens.Black, XBrushes.DarkOrange, rect); rect = new XRect(409, 550, 112, 75); gfx.DrawRectangle(XPens.Black, XBrushes.Red, rect); rect = new XRect(297, 625, 112, 75); gfx.DrawRectangle(XPens.Black, XBrushes.Green, rect); rect = new XRect(409, 625, 112, 75); gfx.DrawRectangle(XPens.Black, XBrushes.Yellow, rect); //Arrows & Texts pen.LineCap = XLineCap.Round; gfx.DrawLine(pen, 409, 625, 381, 606); gfx.DrawLine(pen, 382, 610, 381, 606); gfx.DrawLine(pen, 385, 606, 381, 606); gfx.DrawString("Lean", T10R, XBrushes.Black, 372, 600); gfx.DrawLine(pen, 409, 625, 437, 644); gfx.DrawLine(pen, 436, 640, 437, 644); gfx.DrawLine(pen, 433, 644, 437, 644); gfx.DrawString("Rich", T10R, XBrushes.Black, 430, 655); gfx.DrawLine(pen, 409, 625, 381, 644); gfx.DrawLine(pen, 382, 640, 381, 644); gfx.DrawLine(pen, 385, 644, 381, 644); gfx.DrawString("Inert", T10R, XBrushes.Black, 372, 655); //Point }
private static void DrawVertex(XGraphics g, Vertex v, PresentationSettings presentationSettings, ILayoutProvider layout) { Vector3 p = layout.GetPositionOfNode(v); if (!double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsNaN(p.Z)) g.DrawEllipse(presentationSettings.CustomColors.HasCustomColor(v) ? presentationSettings.CustomColors.GetVertexBrush(v) : presentationSettings.DefaultVertexBrush, presentationSettings.ScaleX(p.X) - presentationSettings.VertexSize / 2, presentationSettings.ScaleY(p.Y) - presentationSettings.VertexSize / 2, presentationSettings.VertexSize, presentationSettings.VertexSize); }