Color, PointF, Size, SizeF — Aspose.Slides FOSS for Python API Reference
The aspose.slides_foss.drawing sub-package provides lightweight geometry and colour primitives that mirror the .NET System.Drawing types. These types appear throughout the API wherever colours, coordinates, or sizes are needed.
Package: aspose.slides_foss.drawing
from aspose.slides_foss.drawing import Color, PointF, Size, SizeFColor
Represents an ARGB colour. All channel values are integers in the range 0–255.
Constructor
from aspose.slides_foss.drawing import Color
c = Color(a=255, r=0, g=70, b=127) # explicit ARGBStatic factory
| Method | Signature | Description |
|---|---|---|
from_argb | Color.from_argb(a, r, g, b) -> Color | Create a colour from four integer channel values. |
Properties (read-only)
| Property | Type | Description |
|---|---|---|
a | int | Alpha channel (0 = transparent, 255 = opaque). |
r | int | Red channel. |
g | int | Green channel. |
b | int | Blue channel. |
Named colour constants
A full set of CSS/X11 named colours is provided as class attributes. Frequently used examples:
| Constant | ARGB |
|---|---|
Color.black | (255, 0, 0, 0) |
Color.white | (255, 255, 255, 255) |
Color.red | (255, 255, 0, 0) |
Color.green | (255, 0, 128, 0) |
Color.blue | (255, 0, 0, 255) |
Color.transparent | (0, 0, 0, 0) |
Color.gray | (255, 128, 128, 128) |
Color.silver | (255, 192, 192, 192) |
Color.navy | (255, 0, 0, 128) |
Color.orange | (255, 255, 165, 0) |
Color.yellow | (255, 255, 255, 0) |
Color.crimson | (255, 220, 20, 60) |
Color.steel_blue | (255, 70, 130, 180) |
Color.dark_green | (255, 0, 100, 0) |
All 140+ standard colours (from alice_blue to yellow_green) are available.
Comparison
Color supports == comparison. Two Color objects are equal if all four channels match.
PointF
Represents a 2D point with floating-point coordinates, in points (pt).
Constructor
from aspose.slides_foss.drawing import PointF
pt = PointF(x=120.5, y=80.0)
pt = PointF() # defaults to (0.0, 0.0)Properties
| Property | Type | Access | Description |
|---|---|---|---|
x | float | Read/Write | Horizontal coordinate in points. |
y | float | Read/Write | Vertical coordinate in points. |
PointF supports == comparison and __repr__ for debugging.
Size
Represents a 2D size with integer dimensions.
Constructor
from aspose.slides_foss.drawing import Size
s = Size(width=640, height=480)
s = Size() # defaults to (0, 0)Properties
| Property | Type | Access | Description |
|---|---|---|---|
width | int | Read/Write | Width in pixels or units (context-dependent). |
height | int | Read/Write | Height. |
SizeF
Represents a 2D size with float dimensions, used for point-based measurements.
Constructor
from aspose.slides_foss.drawing import SizeF
sf = SizeF(width=720.0, height=540.0)
sf = SizeF() # defaults to (0.0, 0.0)Properties
| Property | Type | Access | Description |
|---|---|---|---|
width | float | Read/Write | Width in points. |
height | float | Read/Write | Height in points. |
Usage Example
Set a solid fill colour using Color
import aspose.slides_foss as slides
from aspose.slides_foss import ShapeType, FillType, NullableBool
from aspose.slides_foss.drawing import Color, PointF
from aspose.slides_foss.export import SaveFormat
with slides.Presentation() as prs:
slide = prs.slides[0]
# Shape with custom ARGB fill
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 60, 60, 300, 120)
shape.fill_format.fill_type = FillType.SOLID
shape.fill_format.solid_fill_color.color = Color.from_argb(255, 0, 70, 127)
# Shape fill using a named colour
shape2 = slide.shapes.add_auto_shape(ShapeType.ELLIPSE, 400, 60, 120, 120)
shape2.fill_format.fill_type = FillType.SOLID
shape2.fill_format.solid_fill_color.color = Color.steel_blue
# Use PointF when placing a comment
author = prs.comment_authors.add_author("Dev", "DV")
from datetime import datetime, timezone
author.comments.add_comment(
"Review this layout",
slide,
PointF(100.0, 200.0),
datetime(2025, 1, 1, tzinfo=timezone.utc),
)
prs.save("drawing-demo.pptx", SaveFormat.PPTX)