Classe RectangleShape

Summary: Represents a rectangular shape.

Module: aspose.imaging.shapes

Full Name: aspose.imaging.shapes.RectangleShape

Inheritance: RectangleProjectedShape

Constructors

NameDescription
RectangleShape()Initialise une nouvelle instance de la classe RectangleShape.
RectangleShape(rectangle)Initialise une nouvelle instance de la classe RectangleShape.

Properties

NameTypeAccessDescription
boundsRectangleFrObtient les limites de l’objet.
centerPointFrObtient le centre de la forme.
has_segmentsboolrObtient une valeur indiquant si la forme possède des segments.
left_bottomPointFrObtient le point inférieur gauche du rectangle.
left_topPointFrObtient le point supérieur gauche du rectangle.
rectangle_heightfloatrObtient la hauteur du rectangle.
rectangle_widthfloatrObtient la largeur du rectangle.
right_bottomPointFrObtient le point inférieur droit du rectangle.
right_topPointFrObtient le point supérieur droit du rectangle.
segmentsShapeSegment[]rObtient les segments de la forme.

Methods

NameDescription
get_bounds(matrix)Obtient les limites de l’objet.
get_bounds(matrix, pen)Obtient les limites de l’objet.
transform(transform)Applique la transformation spécifiée à la forme.

Constructor: RectangleShape()

 RectangleShape() 

Initialise une nouvelle instance de la classe RectangleShape.

Constructor: RectangleShape(rectangle)

 RectangleShape(rectangle) 

Initialise une nouvelle instance de la classe RectangleShape.

Parameters:

ParamètreTypeDescription
rectangleRectangleFLe rectangle.

See also:

Example # 1: This examples make use of GraphicsPath and Graphics classes to create and man…

Example # 2: This example creates a new Image and draws a variety of shapes using figures …

Method: get_bounds(matrix)

 get_bounds(matrix) 

Obtient les limites de l’objet.

Parameters:

ParamètreTypeDescription
matrixMatrixLa matrice à appliquer avant que les limites ne soient calculées.

Returns

TypeDescription
RectangleFLes limites estimées de l’objet.

Method: get_bounds(matrix, pen)

 get_bounds(matrix, pen) 

Obtient les limites de l’objet.

Parameters:

ParamètreTypeDescription
matrixMatrixLa matrice à appliquer avant que les limites ne soient calculées.
penPenLe stylo à utiliser pour l’objet. Cela peut influencer la taille des limites de l’objet.

Returns

TypeDescription
RectangleFLes limites estimées de l’objet.

Method: transform(transform)

 transform(transform) 

Applique la transformation spécifiée à la forme.

Parameters:

ParamètreTypeDescription
transformMatrixLa transformation à appliquer.

Examples

This examples make use of GraphicsPath and Graphics classes to create and manipulate figures on an Image surface. Example creates a new Image (of type Tiff), clears the surface and draws paths with the help of GraphicsPath class. At the end draw_path method exposed by Graphics class is called to render the paths on surface.


from aspose.imaging import Image, Graphics, Color, GraphicsPath, Figure, RectangleF, PointF, SizeF
from aspose.imaging import Pen
from aspose.imaging.sources import StreamSource
from aspose.imaging.imageoptions import TiffOptions
from aspose.imaging.fileformats.tiff.enums import TiffExpectedFormat
from aspose.imaging.shapes import RectangleShape, EllipseShape, PieShape


# Créez une instance d'un flux de fichier
with open(r"C:\temp\output.tiff", "w+b") as stream:
	# Créez une instance de TiffOptions et définissez ses différentes propriétés
	tiffOptions = TiffOptions(TiffExpectedFormat.DEFAULT)
	# Définissez la source pour l'instance de ImageOptions
	tiffOptions.source = StreamSource(stream)
	# Créez une instance de Image
	with Image.create(tiffOptions, 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
		graphics_path = GraphicsPath()
		# Créez une instance de la classe Figure
		figure = Figure()
		# Ajoutez des formes à l'objet Figure
		figure.add_shape(RectangleShape(RectangleF(10.0, 10.0, 300.0, 300.0)))
		figure.add_shape(EllipseShape(RectangleF(50.0, 50.0, 300.0, 300.0)))
		figure.add_shape(PieShape(RectangleF(PointF(250.0, 250.0), SizeF(200.0, 200.0)), 0.0, 45.0))
		# Ajoutez l'objet Figure à GraphicsPath
		graphics_path.add_figure(figure)
		# Dessinez le chemin avec l'objet Pen de couleur Noir
		graphics.draw_path(Pen(Color.black, 2.0), graphics_path)
		# enregistrez toutes les modifications.
		image.save()

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