Class SvgGraphics2D

Class SvgGraphics2D

Der Name: Aspose.Imaging.FileFormats.Svg.Graphics Versammlung: Aspose.Imaging.dll (25.4.0)

Bereitzt das Zeichnen von Kommandanten, um ein Svg Bild zu komponieren.

public class SvgGraphics2D

Inheritance

object SvgGraphics2D

Vererbte Mitglieder

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

Grafiken2D(und int, int, int)

Initialisiert eine neue Instanz der Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D Klasse.

public SvgGraphics2D(int width, int height, int dpi)

Parameters

width int

Die Breite des Ausgangs Svg Bild.

height int

Die Breite des Ausgangs Svg Bild.

dpi int

Die Gerätlösung, z. B. 96 Punkte pro Zoll.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und es in PNG rastieren kann.

string dir = "c:\\temp\\";

                                                                                                       int imageWidth = 100;
                                                                                                       int imageHeight = 100;
                                                                                                       int dpi = 96;

                                                                                                       // Create an SVG image of 100x100 px.
                                                                                                       Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                       Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Yellow, 10);
                                                                                                       Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

                                                                                                       // Fill the entire image in red.
                                                                                                       // Draw a yellow rectangle of 10px wide along the image boundaries.
                                                                                                       graphics.FillRectangle(pen, brush, 0, 0, imageWidth, imageHeight);

                                                                                                       // Get the final Svg image which includes all drawing commands
                                                                                                       using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                       {
                                                                                                           svgImage.Save(dir + "test.output.svg");
                                                                                                       }

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

Grafiken2D(SvgImage)

Initialisiert eine neue Instanz der Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D Klasse.

public SvgGraphics2D(SvgImage image)

Parameters

image SvgImage

Das Bild zum Ausführen von Zeichnung Operationen auf.

Methods

DrawArc(Pen, Rectangle, Flut, Flut)

Draht ein Loch, das eine Portion einer Ellipse darstellt, die durch eine Rectangle Struktur angegeben ist.

public void DrawArc(Pen pen, Rectangle rect, float startAngle, float arcAngle)

Parameters

pen Pen

Das Pen, um die Auslinie der Figur zu ziehen.

rect Rectangle

Die Grenzen der Ellipse.

startAngle float

Der Winkel in Gradmessungen wird von der X-Axi bis zum Ausgangspunkt des Arc gemessen.

arcAngle float

Der Winkel in Grades wird von der Startangel-Parameter bis zum Ende des Punkts des Arc gemessen.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

DrawCubicBezier(PointF, PointF, PointF und PointF)

Der kubische Bezier.

public void DrawCubicBezier(Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)

Parameters

pen Pen

Die Pen, die die Farbe, Breite und Stil der Figur bestimmt.

pt1 PointF

Der Ausgangspunkt der Kurve.

pt2 PointF

Der erste Kontrollpunkt für die Kurve.

pt3 PointF

Der zweite Kontrollpunkt für die Kurve.

pt4 PointF

Der Endpunkt der Kurve.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

DrawImage(RasterImage, Punkt)

Zeichnen Sie das angegebenes Bild an der angegebenen Lage.

public void DrawImage(RasterImage image, Point origin)

Parameters

image RasterImage

Das draufene Bild.

origin Point

Der Standort des entworfenen Bildes.

DrawImage(RasterImage, Punkt, Größe)

Zeichnen Sie das angegebenen Bild der angegebenen Größe an der angegebenen Lage.

public void DrawImage(RasterImage image, Point origin, Size size)

Parameters

image RasterImage

Das draufene Bild.

origin Point

Der Standort des entworfenen Bildes.

size Size

Die gewünschte Größe des Bildes.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

DrawImage(Rectangle, Rectangle und RasterImage)

Zeichnen Sie den angegebenen Teil des angegebenen Bildes an der angegebenen Lage und mit der angegebenen Größe.

public void DrawImage(Rectangle srcRect, Rectangle destRect, RasterImage image)

Parameters

srcRect Rectangle

Der Teil des Bildes ist das Objekt zu ziehen.

destRect Rectangle

Die Lage und Größe des gezeichneten Bildes. Das Bild wird geschnitten, um den Rechteck zu passen.

image RasterImage

Das Bild zum Zeichnen.

DrawLine(Pen, int, int, int, int)

Drücken Sie die Linie.

public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)

Parameters

pen Pen

Die Pen, die die Farbe, Breite und Stil der Figur bestimmt.

x1 int

Die X-Koordinate des ersten Punkts.

y1 int

Die Y-Koordinate des ersten Punkts.

x2 int

Die X-Koordinate des zweiten Punkts.

y2 int

Die Y-Koordinate des zweiten Punkts.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

DrawPath(Pen und GraphicsPath)

Drehen Sie den Weg.

public void DrawPath(Pen pen, GraphicsPath path)

Parameters

pen Pen

Das Pen, um die Auslinie der Figur zu ziehen.

path GraphicsPath

Der Weg zum Zeichnen.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

DrawRectangle(Pen, int, int, int, int)

Drehen Sie den Rechteck.

public void DrawRectangle(Pen pen, int x, int y, int width, int height)

Parameters

pen Pen

Das Pen, um die Auslinie der Figur zu ziehen.

x int

Die x-Koordinate des oberen linken Ecks des Rechteckens zum Zeichnen.

y int

Der Y-Koordinat des oberen linken Winkel des Rechteckens zum Zeichnen.

width int

Die Breite des Rechteckens zum Zeichnen.

height int

Die Höhe des Rechteckens zum Zeichnen.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

DrawString(Schrift, String, Punkt, Farbe)

Drehen Sie den Textstring.

public void DrawString(Font font, string text, Point origin, Color textColor)

Parameters

font Font

Die Schrift verwendet, um Text zu machen.

text string

Der Unicode Textstring.

origin Point

Die obere linken Ecke des Textes läuft.

textColor Color

Die Textfarbe.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

EndRecording()

Erhalten Sie die endgültige Svg-Bild, die alle Zeichnungskommandos enthält, die über Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D Objekt ausgeführt werden.

public SvgImage EndRecording()

Returns

SvgImage

Das letzte SVG Bild.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

FillArc(Pen, Brush, Rectangle, Float, Float)

Fülle einen Loch, der einen Teil einer Ellipse darstellt, der durch eine Rectangle Struktur angegeben ist.

public void FillArc(Pen pen, Brush brush, Rectangle rect, float startAngle, float arcAngle)

Parameters

pen Pen

Das Pen, um die Auslinie der Figur zu ziehen.

brush Brush

Die Brust, um das Innere der Figur zu füllen.

rect Rectangle

Die Grenzen der Ellipse.

startAngle float

Der Winkel in Gradmessungen wird von der X-Axi bis zum Ausgangspunkt des Arc gemessen.

arcAngle float

Der Winkel in Grades wird von der Startangel-Parameter bis zum Ende des Punkts des Arc gemessen.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

FillPath(Pen, Brush und GraphicsPath)

Fülle den Weg.

public void FillPath(Pen pen, Brush brush, GraphicsPath path)

Parameters

pen Pen

Das Pen, um die Auslinie der Figur zu ziehen.

brush Brush

Die Brust, um das Innere der Figur zu füllen.

path GraphicsPath

Der Weg zum Zeichnen.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }

FillRectangle(Pen, Brush, int, int, int, int)

Füllen Sie den Rechteck.

public void FillRectangle(Pen pen, Brush brush, int x, int y, int width, int height)

Parameters

pen Pen

Das Pen, um die Auslinie der Figur zu ziehen.

brush Brush

Die Brust, um das Innere der Figur zu füllen.

x int

Die x-Koordinate des oberen linken Ecks des Rechteckens zum Zeichnen.

y int

Der Y-Koordinat des oberen linken Winkel des Rechteckens zum Zeichnen.

width int

Die Breite des Rechteckens zum Zeichnen.

height int

Die Höhe des Rechteckens zum Zeichnen.

Examples

Dieses Beispiel zeigt, wie man ein SVG-Bild der angegebenen Größe erstellen und verschiedene Formen auf ihm mit SvgGraphics2D zeichnen kann.

string dir = "c:\\temp\\";

                                                                                                                                   int imageWidth = 600;
                                                                                                                                   int imageHeight = 400;
                                                                                                                                   int dpi = 96;

                                                                                                                                   Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

                                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.WhiteSmoke, 1), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), 10, 10, 580, 380);

                                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
                                                                                                                                   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);

                                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                                   // Fill an arc
                                                                                                                                   graphics.FillArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.LightCoral, 10), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                                   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
                                                                                                                                       new Aspose.Imaging.PointF(0, 0),
                                                                                                                                       new Aspose.Imaging.PointF(200, 133),
                                                                                                                                       new Aspose.Imaging.PointF(400, 166),
                                                                                                                                       new Aspose.Imaging.PointF(600, 400));

                                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                                   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                   {
                                                                                                                                       graphics.DrawImage(imageToDraw, new Aspose.Imaging.Point(400, 200), new Aspose.Imaging.Size(100, 50));
                                                                                                                                   }

                                                                                                                                   // Draw a text string
                                                                                                                                   graphics.DrawString(new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), "Hello World!", new Aspose.Imaging.Point(200, 300), Aspose.Imaging.Color.DarkRed);

                                                                                                                                   // Create a path to fill
                                                                                                                                   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
                                                                                                                                   figureToFill.IsClosed = true;

                                                                                                                                   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   pathToFill.AddFigure(figureToFill);

                                                                                                                                   figureToFill.AddShapes(new Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
                                                                                                                                           new Aspose.Imaging.Shapes.BezierShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(400, 200),
                                                                                                                                                   new Aspose.Imaging.PointF(500, 100),
                                                                                                                                                   new Aspose.Imaging.PointF(600, 200),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.PolygonShape(
                                                                                                                                               new Aspose.Imaging.PointF[]
                                                                                                                                               {
                                                                                                                                                   new Aspose.Imaging.PointF(300, 100),
                                                                                                                                               }),
                                                                                                                                           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
                                                                                                                                       });

                                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                                   // Create a path to draw
                                                                                                                                   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
                                                                                                                                   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
                                                                                                                                   pathToDraw.AddFigure(figureToDraw);

                                                                                                                                   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
                                                                                                                                       {
                                                                                                                                           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
                                                                                                                                       });

                                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                                   // Get the final SVG image which includes all drawing commands
                                                                                                                                   using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = graphics.EndRecording())
                                                                                                                                   {
                                                                                                                                       svgImage.Save(dir + "test.output.svg");
                                                                                                                                   }
 Deutsch