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, SizeF

Color

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 ARGB

Static factory

MethodSignatureDescription
from_argbColor.from_argb(a, r, g, b) -> ColorCreate a colour from four integer channel values.

Properties (read-only)

PropertyTypeDescription
aintAlpha channel (0 = transparent, 255 = opaque).
rintRed channel.
gintGreen channel.
bintBlue channel.

Named colour constants

A full set of CSS/X11 named colours is provided as class attributes. Frequently used examples:

ConstantARGB
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

PropertyTypeAccessDescription
xfloatRead/WriteHorizontal coordinate in points.
yfloatRead/WriteVertical 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

PropertyTypeAccessDescription
widthintRead/WriteWidth in pixels or units (context-dependent).
heightintRead/WriteHeight.

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

PropertyTypeAccessDescription
widthfloatRead/WriteWidth in points.
heightfloatRead/WriteHeight 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)

See Also