PieShape 类

Summary: Represents a pie shape.

Module: aspose.imaging.shapes

Full Name: aspose.imaging.shapes.PieShape

Inheritance: EllipseShape

Constructors

Name描述
PieShape()初始化一个新的 PieShape 类实例。
PieShape(rectangle, start_angle, sweep_angle)初始化一个新的 PieShape 类实例。

Properties

NameTypeAccess描述
boundsRectangleFr获取对象的边界。
centerPointFr获取形状的中心。
has_segmentsboolr获取一个值,指示形状是否具有段。
left_bottomPointFr获取左下矩形点。
left_topPointFr获取左上矩形点。
rectangle_heightfloatr获取矩形高度。
rectangle_widthfloatr获取矩形宽度。
right_bottomPointFr获取右下矩形点。
right_topPointFr获取右上矩形点。
segmentsShapeSegment[]r获取形状的段。
start_anglefloatr/w获取或设置起始角度。
sweep_anglefloatr/w获取或设置扫掠角度。

Methods

Name描述
get_bounds(matrix)获取对象的边界。
get_bounds(matrix, pen)获取对象的边界。
transform(transform)对形状应用指定的变换。

Constructor: PieShape()

 PieShape() 

初始化一个新的 PieShape 类实例。

Constructor: PieShape(rectangle, start_angle, sweep_angle)

 PieShape(rectangle, start_angle, sweep_angle) 

初始化一个新的 PieShape 类实例。

Parameters:

参数TypeDescription
rectangleRectangleF矩形。
start_anglefloat起始角度。
sweep_anglefloat扫掠角。

See also:

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

Method: get_bounds(matrix)

 get_bounds(matrix) 

获取对象的边界。

Parameters:

参数TypeDescription
matrixMatrix在计算边界之前要应用的矩阵。

Returns

TypeDescription
RectangleF估计的对象边界。

Method: get_bounds(matrix, pen)

 get_bounds(matrix, pen) 

获取对象的边界。

Parameters:

参数TypeDescription
matrixMatrix在计算边界之前要应用的矩阵。
penPen用于对象的笔。这可能会影响对象边界的大小。

Returns

TypeDescription
RectangleF估计的对象边界。

Method: transform(transform)

 transform(transform) 

对形状应用指定的变换。

Parameters:

参数TypeDescription
transformMatrix要应用的变换。

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


# 创建文件流的实例
with open(r"C:\temp\output.tiff", "w+b") as stream:
	# 创建 TiffOptions 的实例并设置其各种属性
	tiffOptions = TiffOptions(TiffExpectedFormat.DEFAULT)
	# 为 ImageOptions 实例设置源
	tiffOptions.source = StreamSource(stream)
	# 创建 Image 的实例
	with Image.create(tiffOptions, 500, 500) as image:
		# 创建并初始化 Graphics 类的实例
		graphics = Graphics(image)
		# 清除 Graphics 表面
		graphics.clear(Color.wheat);
		# 创建 GraphicsPath 类的实例
		graphics_path = GraphicsPath()
		# 创建 Figure 类的实例
		figure = Figure()
		# 向 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))
		# 将 Figure 对象添加到 GraphicsPath
		graphics_path.add_figure(figure)
		# 使用颜色为 Black 的 Pen 对象绘制路径
		graphics.draw_path(Pen(Color.black, 2.0), graphics_path)
		# 保存所有更改。
		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

#创建 BmpOptions 的实例并设置其各种属性            
with BmpOptions() as bmpOptions:
	bmpOptions.bits_per_pixel = 24
	#创建 FileCreateSource 的实例并将其分配为 BmpOptions 实例的 Source
	#第二个布尔参数决定要创建的文件是否为临时文件
	bmpOptions.source = FileCreateSource(r"c:\temp\output.bmp", False)
	#创建 Image 实例
	with Image.create(bmpOptions, 500, 500) as image:
		# 创建并初始化 Graphics 类的实例
		graphics = Graphics(image)
		# 清除 Graphics 表面
		graphics.clear(Color.wheat)
		# 创建 GraphicsPath 类的实例
		graphicspath = GraphicsPath()
		#创建 Figure 类的实例
		figure1 = Figure()
		# 向 Figure 对象添加形状
		figure1.add_shape(EllipseShape(RectangleF(50, 50, 300, 300)))
		figure1.add_shape(PieShape(Rectangle(Point(110, 110), Size(200, 200)), 0, 90))
		# 创建 Figure 类的实例
		figure2 = Figure()
		# 向 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))))
		# 将 Figure 对象添加到 GraphicsPath
		graphicspath.add_figures([figure1, figure2])
		# 使用颜色为 Black 的 Pen 对象绘制路径
		graphics.draw_path(Pen(Color.black, 2.0), graphicspath)
		# 保存所有更改。
		image.save()