Skip to content

Commit 5abbdaf

Browse files
authored
Fix color deserialization, add schema (#1915)
Signed-off-by: Spencer Magnusson <[email protected]>
1 parent f662359 commit 5abbdaf

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed

docs/tutorials/otio-serialized-schema-only-fields.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ parameters:
3131

3232
## Module: opentimelineio.core
3333

34+
### Color.1
35+
36+
parameters:
37+
- *a*
38+
- *b*
39+
- *g*
40+
- *name*
41+
- *r*
42+
3443
### Composable.1
3544

3645
parameters:

docs/tutorials/otio-serialized-schema.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@ parameters:
5656

5757
## Module: opentimelineio.core
5858

59+
### Color.1
60+
61+
*full module path*: `opentimelineio.core.Color`
62+
63+
*documentation*:
64+
65+
```
66+
:class:`Color` is a definition of red, green, blue, and alpha double floating point values, allowing
67+
conversion between different formats. To be considered interoperable, the sRGB transfer function
68+
encoded values, ranging between zero and one, are expected to be accurate to within 1/255 of the
69+
intended value. Round-trip conversions may not be guaranteed outside that. This Color class is meant
70+
for use in user interface elements, like marker or clip coloring, NOT for image pixel content.
71+
```
72+
73+
parameters:
74+
- *a*:
75+
- *b*:
76+
- *g*:
77+
- *name*:
78+
- *r*:
79+
5980
### Composable.1
6081

6182
*full module path*: `opentimelineio.core.Composable`

src/opentimelineio/deserialization.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,13 @@ SerializableObject::Reader::_decode(_Resolver& resolver)
590590
}
591591
else if (schema_name_and_version == "Color.1")
592592
{
593-
float r, g, b, a;
593+
double r, g, b, a;
594594
std::string name;
595-
return _fetch("r", &r)
595+
return _fetch("name", &name)
596+
&& _fetch("r", &r)
596597
&& _fetch("g", &g)
597598
&& _fetch("b", &b)
598599
&& _fetch("a", &a)
599-
&& _fetch("name", &name)
600600
? std::any(Color(r, g, b, a, name))
601601
: std::any();
602602
}

src/py-opentimelineio/opentimelineio/console/autogen_serialized_datamodel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def _generate_model_for_module(mod, classes, modules):
159159
otio.opentime.RationalTime,
160160
otio.opentime.TimeRange,
161161
otio.opentime.TimeTransform,
162+
otio.core.Color
162163
)
163164
)
164165
]

src/py-opentimelineio/opentimelineio/core/_core_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"opentime.RationalTime",
2727
"opentime.TimeRange",
2828
"opentime.TimeTransform",
29+
"opentimelineio.core.Color",
2930
"opentimelineio.core.SerializableObject"
3031
)
3132

tests/test_json_backend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def test_timetransform(self):
4747
tt = otio.opentime.TimeTransform()
4848
self.check_against_baseline(tt, "empty_timetransform")
4949

50+
def test_color(self):
51+
tt = otio.core.Color()
52+
self.check_against_baseline(tt, "empty_color")
53+
5054
def test_track(self):
5155
st = otio.schema.Track(
5256
name="test_track",

0 commit comments

Comments
 (0)