Canvas
A Canvas represents a single image area within a context. It has dimensions,
optional effective/photosite/physical dimensions, and contains framing decisions
that describe how content is framed within the canvas.
fdl.Canvas(*, id, label='', source_canvas_id, dimensions, anamorphic_squeeze=1.0, effective_dimensions=None, effective_anchor_point=None, photosite_dimensions=None, physical_dimensions=None, framing_decisions=None)
Bases: HandleWrapper
Canvas facade wrapping a C fdl_canvas_t handle.
custom_attrs
property
Return all custom attributes as a dictionary.
add_framing_decision(id, label, framing_intent_id, dimensions, anchor_point)
Add a framing decision to this canvas.
custom_attrs_count()
Return the number of custom attributes on this object.
from_model(model)
classmethod
Create a standalone Canvas facade from a Pydantic model.
Note: Creates a temporary backing document. The returned object is self-contained but not attached to any parent FDL document.
get_custom_attr(name)
Get a custom attribute value by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Attribute name (without |
required |
Returns:
| Type | Description |
|---|---|
str | int | float | bool | PointFloat | DimensionsFloat | DimensionsInt | None
|
The attribute value, or None if not found. |
get_effective_rect()
Get effective rect or None if not defined.
get_rect()
Get canvas rect as (0, 0, width, height).
has_custom_attr(name)
Check if a custom attribute exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Attribute name (without |
required |
remove_custom_attr(name)
Remove a custom attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Attribute name (without |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the attribute was removed, False if it was not found. |
set_custom_attr(name, value)
Set a custom attribute. Type is inferred from value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Attribute name (without |
required |
value
|
str | int | float | bool | PointFloat | DimensionsFloat | DimensionsInt
|
Attribute value (str, int, float, bool, PointFloat, DimensionsFloat, or DimensionsInt). |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If value is not str, int, float, bool, PointFloat, DimensionsFloat, or DimensionsInt. |
ValueError
|
If an attribute with the same name exists with a different type. |
set_effective(dims, anchor)
Set effective dimensions and anchor point on this canvas.
to_model()
Convert to a Pydantic CanvasModel instance.
Returns a pure-data Pydantic model suitable for serialization, API responses, and interoperability with web frameworks.