SvgGraphics2D

Inheritance: java.lang.Object

public class SvgGraphics2D

يوفر أوامر رسم لتكوين صورة Svg.

المنشئات

المنشئالوصف
SvgGraphics2D(int width, int height, int dpi)يُنشئ نسخة جديدة من الفئة SvgGraphics2D.
SvgGraphics2D(SvgImage image)يُنشئ نسخة جديدة من الفئة SvgGraphics2D.

الطرق

طريقةالوصف
drawImage(RasterImage image, Point origin)يرسم الصورة المحددة في الموقع المحدد.
drawImage(RasterImage image, Point origin, Size size)يرسم الصورة المحددة بالحجم المحدد في الموقع المحدد.
drawImage(Rectangle srcRect, Rectangle destRect, RasterImage image)يرسم الجزء المحدد من الصورة المحددة في الموقع المحدد وبالحجم المحدد.
drawArc(Pen pen, Rectangle rect, float startAngle, float arcAngle)يرسم قوسًا يمثل جزءًا من إهليلج محدد بواسطة بنية Rectangle.
fillArc(Pen pen, Brush brush, Rectangle rect, float startAngle, float arcAngle)يملأ قوسًا يمثل جزءًا من إهليلج محدد بواسطة بنية Rectangle.
drawCubicBezier(Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)يرسم منحنى بيزير مكعب.
drawString(Font font, String text, Point origin, Color textColor)يرسم سلسلة النص.
drawLine(Pen pen, int x1, int y1, int x2, int y2)يرسم الخط.
drawPath(Pen pen, GraphicsPath path)يرسم المسار.
fillPath(Pen pen, Brush brush, GraphicsPath path)يملأ المسار.
drawRectangle(Pen pen, int x, int y, int width, int height)يرسم المستطيل.
fillRectangle(Pen pen, Brush brush, int x, int y, int width, int height)يملأ المستطيل.
endRecording()يحصل على صورة Svg النهائية التي تشمل جميع أوامر الرسم التي تم تنفيذها عبر كائن SvgGraphics2D.

Example: This example shows how to create an SVG image of the specified size and draw different shapes on it using SvgGraphics2D.

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

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

com.aspose.imaging.fileformats.svg.graphics.SvgGraphics2D graphics = new com.aspose.imaging.fileformats.svg.graphics.SvgGraphics2D(imageWidth, imageHeight, dpi);

// ارسم مستطيلًا أسود على حدود الصورة باستخدام قلم أسود بعرض بكسل واحد.
graphics.drawRectangle(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 1), 0, 0, imageWidth, imageHeight);

// املأ مستطيلًا بلون دخان أبيض.
graphics.fillRectangle(
        new com.aspose.imaging.Pen(com.aspose.imaging.Color.getWhiteSmoke(), 1),
        new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getWhiteSmoke()), 10, 10, 580, 380);

// ارسم خطين قطريين باستخدام قلم أخضر داكن بعرض بكسل واحد.
graphics.drawLine(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getDarkGreen(), 1), 0, 0, imageWidth, imageHeight);
graphics.drawLine(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getDarkGreen(), 1), 0, imageHeight, imageWidth, 0);

// ارسم قوسًا داخل المستطيل {0, 0, 200, 200} باستخدام قلم أزرق بعرض بكسلين.
graphics.drawArc(
        new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2),
        new com.aspose.imaging.Rectangle(0, 0, 200, 200), 90, 270);

// املأ قوسًا
graphics.fillArc(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getLightCoral(), 10),
        new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getLightSkyBlue()),
        new com.aspose.imaging.Rectangle(0, 0, 150, 150), 90, 270);

// ارسم منحنى بيزير مكعب باستخدام قلم أحمر بعرض بكسلين.
graphics.drawCubicBezier(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2),
        new com.aspose.imaging.PointF(0, 0),
        new com.aspose.imaging.PointF(200, 133),
        new com.aspose.imaging.PointF(400, 166),
        new com.aspose.imaging.PointF(600, 400));

// ارسم صورة نقطية بالحجم المحدد في الموقع المحدد.
// يتم تحجيم الصورة لتناسب المستطيل المطلوب.
com.aspose.imaging.RasterImage imageToDraw = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.load(dir + "sample.bmp");
try {
    graphics.drawImage(imageToDraw, new com.aspose.imaging.Point(400, 200), new com.aspose.imaging.Size(100, 50));
} finally {
    imageToDraw.dispose();
}

// ارسم سلسلة نصية
graphics.drawString(
        new com.aspose.imaging.Font("Arial", 48, com.aspose.imaging.FontStyle.Regular),
        "Hello World!",
        new com.aspose.imaging.Point(200, 300),
        com.aspose.imaging.Color.getDarkRed());

// إنشاء مسار للتعبئة
com.aspose.imaging.Figure figureToFill = new com.aspose.imaging.Figure();
figureToFill.setClosed(true);

com.aspose.imaging.GraphicsPath pathToFill = new com.aspose.imaging.GraphicsPath();
pathToFill.addFigure(figureToFill);

figureToFill.addShapes(new com.aspose.imaging.Shape[]
        {
                new com.aspose.imaging.shapes.ArcShape(new com.aspose.imaging.RectangleF(400, 0, 200, 100), 45, 300),
                new com.aspose.imaging.shapes.BezierShape(
                        new com.aspose.imaging.PointF[]
                                {
                                        new com.aspose.imaging.PointF(300, 200),
                                        new com.aspose.imaging.PointF(400, 200),
                                        new com.aspose.imaging.PointF(500, 100),
                                        new com.aspose.imaging.PointF(600, 200),
                                }),
                new com.aspose.imaging.shapes.PolygonShape(
                        new com.aspose.imaging.PointF[]
                                {
                                        new com.aspose.imaging.PointF(300, 100),
                                }),
                new com.aspose.imaging.shapes.RectangleShape(
                        new com.aspose.imaging.RectangleF(0, 100, 200, 200)),
        });

// املأ المسار باستخدام فرشاة صفراء وقلم أخضر لرسم الحدود.
graphics.fillPath(
        new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2),
        new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getYellow()), pathToFill);

// إنشاء مسار للرسم
com.aspose.imaging.GraphicsPath pathToDraw = new com.aspose.imaging.GraphicsPath();
com.aspose.imaging.Figure figureToDraw = new com.aspose.imaging.Figure();
pathToDraw.addFigure(figureToDraw);

figureToDraw.addShapes(new com.aspose.imaging.Shape[]
        {
                new com.aspose.imaging.shapes.ArcShape(new com.aspose.imaging.RectangleF(200, 200, 200, 200), 0, 360),
        });

// ارسم المسار باستخدام قلم برتقالي بعرض 5 بكسل.
graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 5), pathToDraw);

// احصل على صورة SVG النهائية التي تشمل جميع أوامر الرسم
com.aspose.imaging.fileformats.svg.SvgImage svgImage = graphics.endRecording();
try {
    svgImage.save(dir + "test.output.svg");
} finally {
    svgImage.dispose();
}

SvgGraphics2D(int width, int height, int dpi)

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

يُنشئ نسخة جديدة من الفئة SvgGraphics2D.

Parameters:

معاملنوعالوصف
widthintعرض صورة Svg الناتجة.
heightintعرض صورة Svg الناتجة.
dpiintدقة الجهاز، مثال 96 نقطة في البوصة.

SvgGraphics2D(SvgImage image)

public SvgGraphics2D(SvgImage image)

يُنشئ نسخة جديدة من الفئة SvgGraphics2D.

Parameters:

معاملنوعالوصف
imageSvgImageالصورة التي تُجرى عليها عمليات الرسم.

drawImage(RasterImage image, Point origin)

public final void drawImage(RasterImage image, Point origin)

يرسم الصورة المحددة في الموقع المحدد.

Parameters:

معاملنوعالوصف
imageRasterImageالصورة المرسومة.
originPointموقع الصورة المرسومة.

drawImage(RasterImage image, Point origin, Size size)

public final void drawImage(RasterImage image, Point origin, Size size)

يرسم الصورة المحددة بالحجم المحدد في الموقع المحدد.

Parameters:

معاملنوعالوصف
imageRasterImageالصورة المرسومة.
originPointموقع الصورة المرسومة.
sizeSizeالحجم المطلوب للصورة المرسومة.

drawImage(Rectangle srcRect, Rectangle destRect, RasterImage image)

public final void drawImage(Rectangle srcRect, Rectangle destRect, RasterImage image)

يرسم الجزء المحدد من الصورة المحددة في الموقع المحدد وبالحجم المحدد.

Parameters:

معاملنوعالوصف
srcRectRectangleالجزء من كائن الصورة الذي سيتم رسمه.
destRectRectangleالموقع والحجم للصورة المرسومة. يتم تحجيم الصورة لتناسب المستطيل.
imageRasterImageالصورة المراد رسمها.

drawArc(Pen pen, Rectangle rect, float startAngle, float arcAngle)

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

يرسم قوسًا يمثل جزءًا من إهليلج محدد بواسطة بنية Rectangle.

Parameters:

معاملنوعالوصف
penPenالقلم لرسم حدود الشكل.
rectRectangleحدود القطع الناقص.
startAnglefloatالزاوية بالدرجات المقاسة باتجاه عقارب الساعة من محور x إلى نقطة بدء القوس.
arcAnglefloatالزاوية بالدرجات المقاسة باتجاه عقارب الساعة من معامل startAngle إلى نقطة نهاية القوس.

fillArc(Pen pen, Brush brush, Rectangle rect, float startAngle, float arcAngle)

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

يملأ قوسًا يمثل جزءًا من إهليلج محدد بواسطة بنية Rectangle.

Parameters:

معاملنوعالوصف
penPenالقلم لرسم حدود الشكل.
brushBrushالفرشاة لملء داخل الشكل.
rectRectangleحدود القطع الناقص.
startAnglefloatالزاوية بالدرجات المقاسة باتجاه عقارب الساعة من محور x إلى نقطة بدء القوس.
arcAnglefloatالزاوية بالدرجات المقاسة باتجاه عقارب الساعة من معامل startAngle إلى نقطة نهاية القوس.

drawCubicBezier(Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)

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

يرسم منحنى بيزير مكعب.

Parameters:

معاملنوعالوصف
penPenالقلم الذي يحدد اللون والعرض والنمط للشكل.
pt1PointFنقطة البداية للمنحنى.
pt2PointFنقطة التحكم الأولى للمنحنى.
pt3PointFنقطة التحكم الثانية للمنحنى.
pt4PointFنقطة النهاية للمنحنى.

drawString(Font font, String text, Point origin, Color textColor)

public final void drawString(Font font, String text, Point origin, Color textColor)

يرسم سلسلة النص.

Parameters:

معاملنوعالوصف
fontFontالخط المستخدم لعرض النص.
textjava.lang.Stringسلسلة النص Unicode.
originPointالزاوية العلوية اليسرى لتشغيل النص.
textColorColorلون النص.

drawLine(Pen pen, int x1, int y1, int x2, int y2)

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

يرسم الخط.

Parameters:

معاملنوعالوصف
penPenالقلم الذي يحدد اللون والعرض والنمط للشكل.
x1intالإحداثي السيني للنقطة الأولى.
y1intالإحداثي الصادي للنقطة الأولى.
x2intالإحداثي السيني للنقطة الثانية.
y2intالإحداثي الصادي للنقطة الثانية.

drawPath(Pen pen, GraphicsPath path)

public final void drawPath(Pen pen, GraphicsPath path)

يرسم المسار.

Parameters:

معاملنوعالوصف
penPenالقلم لرسم حدود الشكل.
pathGraphicsPathالمسار للرسم.

fillPath(Pen pen, Brush brush, GraphicsPath path)

public final void fillPath(Pen pen, Brush brush, GraphicsPath path)

يملأ المسار.

Parameters:

معاملنوعالوصف
penPenالقلم لرسم حدود الشكل.
brushBrushالفرشاة لملء داخل الشكل.
pathGraphicsPathالمسار للرسم.

drawRectangle(Pen pen, int x, int y, int width, int height)

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

يرسم المستطيل.

Parameters:

معاملنوعالوصف
penPenالقلم لرسم حدود الشكل.
xintالإحداثي السيني للزاوية العليا اليسرى للمستطيل المراد رسمه.
yintالإحداثي الصادي للزاوية العليا اليسرى للمستطيل المراد رسمه.
widthintعرض المستطيل المراد رسمه.
heightintارتفاع المستطيل المراد رسمه.

fillRectangle(Pen pen, Brush brush, int x, int y, int width, int height)

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

يملأ المستطيل.

Parameters:

معاملنوعالوصف
penPenالقلم لرسم حدود الشكل.
brushBrushالفرشاة لملء داخل الشكل.
xintالإحداثي السيني للزاوية العليا اليسرى للمستطيل المراد رسمه.
yintالإحداثي الصادي للزاوية العليا اليسرى للمستطيل المراد رسمه.
widthintعرض المستطيل المراد رسمه.
heightintارتفاع المستطيل المراد رسمه.

endRecording()

public final SvgImage endRecording()

يحصل على صورة Svg النهائية التي تشمل جميع أوامر الرسم التي تم تنفيذها عبر كائن SvgGraphics2D.

Returns: SvgImage - The final Svg image.