Skip to content

Commit

Permalink
Add opacity and draw_order to ImageEncoded constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jul 13, 2024
1 parent 4d46773 commit db62482
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rerun_py/rerun_sdk/rerun/archetypes/image_encoded_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

if TYPE_CHECKING:
from ..components import MediaType
from ..datatypes import Float32Like


def guess_media_type(path: str | pathlib.Path) -> MediaType | None:
Expand All @@ -31,6 +32,8 @@ def __init__(
path: str | pathlib.Path | None = None,
contents: datatypes.BlobLike | None = None,
media_type: datatypes.Utf8Like | None = None,
opacity: Float32Like | None = None,
draw_order: Float32Like | None = None,
):
"""
Create a new instance of the ImageEncoded archetype.
Expand All @@ -56,6 +59,15 @@ def __init__(
or the viewer will try to guess from the contents (magic header).
If the media type cannot be guessed, the viewer won't be able to render the asset.
opacity:
Opacity of the image, useful for layering several images.
Defaults to 1.0 (fully opaque).
draw_order:
An optional floating point value that specifies the 2D drawing
order. Objects with higher values are drawn on top of those with
lower values.
"""

with catch_and_log_exceptions(context=self.__class__.__name__):
Expand All @@ -69,7 +81,7 @@ def __init__(
if media_type is None:
media_type = guess_media_type(str(path))

self.__attrs_init__(blob=blob, media_type=media_type)
self.__attrs_init__(blob=blob, media_type=media_type, draw_order=draw_order, opacity=opacity)
return

self.__attrs_clear__()

0 comments on commit db62482

Please sign in to comment.