Classe PolygonShape
Contenu
[
Cacher
]Summary: Represents a polygon shape.
Module: aspose.imaging.shapes
Full Name: aspose.imaging.shapes.PolygonShape
Inheritance: IOrderedShape, Shape
Constructors
| Name | Description |
|---|---|
| PolygonShape() | Initialise une nouvelle instance de la classe PolygonShape. |
| PolygonShape(points) | Initialise une nouvelle instance de la classe PolygonShape. |
| PolygonShape(points, is_closed) | Initialise une nouvelle instance de la classe PolygonShape. |
Properties
| Name | Type | Access | Description |
|---|---|---|---|
| bounds | RectangleF | r | Obtient les limites de l’objet. |
| center | PointF | r | Obtient le centre de la forme. |
| end_point | PointF | r | Obtient le point final de la forme. |
| has_segments | bool | r | Obtient une valeur indiquant si la forme possède des segments. |
| is_closed | bool | r/w | Obtient ou définit une valeur indiquant si la forme est fermée. |
| points | PointF[] | r/w | Obtient ou définit les points de la courbe. |
| segments | ShapeSegment[] | r | Obtient les segments de la forme. |
| start_point | PointF | r | Obtient le point de départ de la forme. |
Methods
| Name | Description |
|---|---|
| get_bounds(matrix) | Obtient les limites de l’objet. |
| get_bounds(matrix, pen) | Obtient les limites de l’objet. |
| reverse() | Inverse l’ordre des points pour cette forme. |
| transform(transform) | Applique la transformation spécifiée à la forme. |
Constructor: PolygonShape()
PolygonShape()
Initialise une nouvelle instance de la classe PolygonShape.
Constructor: PolygonShape(points)
PolygonShape(points)
Initialise une nouvelle instance de la classe PolygonShape.
Parameters:
| Paramètre | Type | Description |
|---|---|---|
| points | PointF[] | Le tableau de points. |
Constructor: PolygonShape(points, is_closed)
PolygonShape(points, is_closed)
Initialise une nouvelle instance de la classe PolygonShape.
Parameters:
| Paramètre | Type | Description |
|---|---|---|
| points | PointF[] | Le tableau de points. |
| is_closed | bool | Si défini sur |
Method: get_bounds(matrix)
get_bounds(matrix)
Obtient les limites de l’objet.
Parameters:
| Paramètre | Type | Description |
|---|---|---|
| matrix | Matrix | La matrice à appliquer avant que les limites ne soient calculées. |
Returns
| Type | Description |
|---|---|
| RectangleF | Les limites estimées de l’objet. |
Method: get_bounds(matrix, pen)
get_bounds(matrix, pen)
Obtient les limites de l’objet.
Parameters:
| Paramètre | Type | Description |
|---|---|---|
| matrix | Matrix | La matrice à appliquer avant que les limites ne soient calculées. |
| pen | Pen | Le stylo à utiliser pour l’objet. Cela peut influencer la taille des limites de l’objet. |
Returns
| Type | Description |
|---|---|
| RectangleF | Les limites estimées de l’objet. |
Method: transform(transform)
transform(transform)
Applique la transformation spécifiée à la forme.
Parameters:
| Paramètre | Type | Description |
|---|---|---|
| transform | Matrix | La transformation à appliquer. |
Examples
This example creates a new Image and draws a variety of shapes using figures and GraphicsPath on the Image surface
from aspose.imaging import Image, Graphics, Color, GraphicsPath, Figure, RectangleF, Rectangle, Size
from aspose.imaging import Point, PointF, Pen
from aspose.imaging.imageoptions import BmpOptions
from aspose.imaging.sources import FileCreateSource
from aspose.imaging.shapes import EllipseShape, PieShape, ArcShape, PolygonShape, RectangleShape
from os.path import join as path_join
#Crée une instance de BmpOptions et définissez ses différentes propriétés
with BmpOptions() as bmpOptions:
bmpOptions.bits_per_pixel = 24
#Créez une instance de FileCreateSource et assignez‑la comme Source pour l'instance de BmpOptions
#Le deuxième paramètre booléen détermine si le fichier à créer est temporaire ou non
bmpOptions.source = FileCreateSource(r"c:\temp\output.bmp", False)
#Créez une instance de Image
with Image.create(bmpOptions, 500, 500) as image:
# Créez et initialisez une instance de la classe Graphics
graphics = Graphics(image)
# Efface la surface Graphics
graphics.clear(Color.wheat)
# Créez une instance de la classe GraphicsPath
graphicspath = GraphicsPath()
#Créez une instance de la classe Figure
figure1 = Figure()
# Ajoutez une forme à l'objet Figure
figure1.add_shape(EllipseShape(RectangleF(50, 50, 300, 300)))
figure1.add_shape(PieShape(Rectangle(Point(110, 110), Size(200, 200)), 0, 90))
# Créez une instance de la classe Figure
figure2 = Figure()
# Ajoutez une forme à l'objet Figure
figure2.add_shape(ArcShape(RectangleF(10, 10, 300, 300), 0, 45))
figure2.add_shape(
PolygonShape([PointF(150, 10), PointF(150, 200), PointF(250, 300), PointF(350, 400)], True))
figure2.add_shape(RectangleShape(RectangleF(Point(250, 250), Size(200, 200))))
# Ajoutez l'objet Figure à GraphicsPath
graphicspath.add_figures([figure1, figure2])
# Dessinez le chemin avec l'objet Pen de couleur Noir
graphics.draw_path(Pen(Color.black, 2.0), graphicspath)
# enregistrez toutes les modifications.
image.save()