xr_ai_tools.image_polygon#

Fill an image-space polygon with opaque magenta pixels.

Classes#

ImagePoint

One non-negative source-image pixel coordinate.

ImagePolygonFillRequest

Fill the polygon defined by ordered image-space vertices.

ImagePolygonFillResult

A lossless PNG copy containing the filled polygon.

ImagePolygonFillTool

Create a magenta polygon overlay without changing the source image.

Functions#

fill_polygon_magenta(→ bytes)

Return lossless PNG bytes with the supplied polygon filled #FF00FF.

Module Contents#

class xr_ai_tools.image_polygon.ImagePoint#

One non-negative source-image pixel coordinate.

x: float#

Horizontal pixel coordinate from the left edge.

y: float#

Vertical pixel coordinate from the top edge.

class xr_ai_tools.image_polygon.ImagePolygonFillRequest#

Fill the polygon defined by ordered image-space vertices.

image: xr_ai_tools.image.ImageReference#

Source image returned by an image tool or supplied by the caller.

coordinates: list[ImagePoint]#

Ordered vertices, with the final vertex connected to the first.

class xr_ai_tools.image_polygon.ImagePolygonFillResult#

A lossless PNG copy containing the filled polygon.

image: xr_ai_tools.image.ImageReference | None#

Opaque reference to the edited PNG image when available.

available: bool#

Whether the supplied image and polygon produced an edited image.

message: str | None#

Recoverable failure detail when no edited image was produced.

xr_ai_tools.image_polygon.fill_polygon_magenta(
source: xr_ai_tools.image.ImageInput,
coordinates: collections.abc.Sequence[ImagePoint],
) bytes#

Return lossless PNG bytes with the supplied polygon filled #FF00FF.

class xr_ai_tools.image_polygon.ImagePolygonFillTool(*, images: xr_ai_tools.image.ImageRegistry)#

Create a magenta polygon overlay without changing the source image.