Class SvgGraphics2D

Class SvgGraphics2D

Numele spaţiului: Aspose.Imaging.FileFormats.Svg.Graphics Asamblare: Aspose.Imaging.dll (25.4.0)

Oferă desenarea comandelor pentru a compune o imagine Svg.

public class SvgGraphics2D

Inheritance

object SvgGraphics2D

Membrii moștenitori

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

Constructors

Grafica 2D(int, int, int)

Inițializează o nouă instanță a clasei Aspose.Imaging.FileFormats.Svg.Graphics.D.

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

Parameters

width int

Amploarea imaginii de ieșire Svg.

height int

Amploarea imaginii de ieșire Svg.

dpi int

Rezoluția dispozitivului, de exemplu, 96 puncte pe inch.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să o rasterizați la PNG.

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");
                                                                                                       }

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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");
                                                                                                                                   }

Grafica 2D(SvgImage)

Inițializează o nouă instanță a clasei Aspose.Imaging.FileFormats.Svg.Graphics.D.

public SvgGraphics2D(SvgImage image)

Parameters

image SvgImage

Imaginea pentru a efectua operațiuni de desenare pe.

Methods

DrawArc(Pen, rectangle, float, float)

Drage un arc care reprezintă o parte a unui elips specificat de o structură rectangulară.

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

Parameters

pen Pen

Penul pentru a trage rezultatul figurei.

rect Rectangle

Frontierele elipsei.

startAngle float

Unghiul în grade măsoară în mod orar de la x-axis până la punctul de pornire al arcului.

arcAngle float

Unghiul în grade este măsurat în mod orar de la parametrul de pornireAngle până la sfârșitul punctului arcului.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Punctul F, PointF, PointF, PointF)

Cumpărați cuțitul cubic.

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

Parameters

pen Pen

Penul care determină culoarea, lățimea și stilul figurii.

pt1 PointF

Punctul de pornire al curvei.

pt2 PointF

Primul punct de control al curvei.

pt3 PointF

Al doilea punct de control al curvei.

pt4 PointF

Punctul final al curvei.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Cuvânt cheie, punct)

Imaginea specificată este înlocuită în locația indicată.

public void DrawImage(RasterImage image, Point origin)

Parameters

image RasterImage

Imaginea capturată.

origin Point

Localizarea imaginii realizate.

DrawImage(RasterImage, punct, dimensiune)

Imaginea specificată a mărimii specificate se încadrează în locul specificat.

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

Parameters

image RasterImage

Imaginea capturată.

origin Point

Localizarea imaginii realizate.

size Size

Dimensiunea dorită a imaginii.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Cuvânt cheie: Rectangle, RasterImage)

Încărcați porția specificată a imaginii specificate la locul specificat și cu dimensiunea specifică.

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

Parameters

srcRect Rectangle

O parte a imaginii este obiectul de desenare.

destRect Rectangle

Poziția și dimensiunea imaginii desenate. imaginea este scalată pentru a se potrivi dreptunghiului.

image RasterImage

Imaginea pe care trebuie să o desenăm.

DrawLine(Pân, int, int, int, int)

Încărcați linia.

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

Parameters

pen Pen

Penul care determină culoarea, lățimea și stilul figurii.

x1 int

Coordonatul X al primului punct.

y1 int

coordonate a primului punct.

x2 int

Coordonatul X al celui de-al doilea punct.

y2 int

coordonate a celui de-al doilea punct.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Cuvânt cheie, grafică)

Încărcați drumul.

public void DrawPath(Pen pen, GraphicsPath path)

Parameters

pen Pen

Penul pentru a trage rezultatul figurei.

path GraphicsPath

Calea de a trage.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Pân, int, int, int, int)

Încărcați rectanglul.

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

Parameters

pen Pen

Penul pentru a trage rezultatul figurei.

x int

Coordonatul x al colțului stâng de sus al rectanglului pentru a trage.

y int

Coordonatul y al colțului stâng de sus al rectanglului pentru a trage.

width int

Amploarea rectanglului pentru a trage.

height int

Înălțimea rectanglului pentru a trage.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Font, string, punct, culoare)

Încărcați stringul text.

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

Parameters

font Font

Fontul a fost folosit pentru a face text.

text string

Unicode text string.

origin Point

Corpul stâng de sus al textului funcționează.

textColor Color

Culoarea textului.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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()

Obțineți imaginea finală Svg care include toate comenzi de desen efectuate prin intermediul Aspose.Imaging.FileFormats.Svg.Graphics.

public SvgImage EndRecording()

Returns

SvgImage

Imaginea finală a lui Svg.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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, brățară, rectangle, float)

Îmbunătățește un arc care reprezintă o porție de elipsă specificată de o structură rectangulară.

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

Parameters

pen Pen

Penul pentru a trage rezultatul figurei.

brush Brush

Brățarul pentru a umple interiorul figurii.

rect Rectangle

Frontierele elipsei.

startAngle float

Unghiul în grade măsoară în mod orar de la x-axis până la punctul de pornire al arcului.

arcAngle float

Unghiul în grade este măsurat în mod orar de la parametrul de pornireAngle până la sfârșitul punctului arcului.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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, brățară, GraphicsPath)

Îmbunătăţeşte calea.

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

Parameters

pen Pen

Penul pentru a trage rezultatul figurei.

brush Brush

Brățarul pentru a umple interiorul figurii.

path GraphicsPath

Calea de a trage.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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(Cuvânt cheie: int, int , int)

Împlinește rectanglul.

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

Parameters

pen Pen

Penul pentru a trage rezultatul figurei.

brush Brush

Brățarul pentru a umple interiorul figurii.

x int

Coordonatul x al colțului stâng de sus al rectanglului pentru a trage.

y int

Coordonatul y al colțului stâng de sus al rectanglului pentru a trage.

width int

Amploarea rectanglului pentru a trage.

height int

Înălțimea rectanglului pentru a trage.

Examples

Acest exemplu arată cum să creați o imagine SVG a dimensiunii specificate și să trageți diferite forme pe ea folosind SvgGraphics2D.

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");
                                                                                                                                   }
 Română