+# *Transfer Function Transform*
+# -------------------------------------------------------------------------
+def create_transfer_colorspace(name='transfer',
+ transfer_function_name='transfer_function',
+ transfer_function=lambda x: x,
+ lut_directory='/tmp',
+ lut_resolution_1d=1024,
+ aliases=[]):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
+ cs = ColorSpace(name)
+ cs.description = 'The %s color space' % name
+ cs.aliases = aliases
+ cs.equality_group = name
+ cs.family = 'Utility'
+ cs.is_data = False
+
+ # A linear space needs allocation variables
+ cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
+ cs.allocation_vars = [0, 1]
+
+ # Sample the transfer function
+ data = array.array('f', '\0' * lut_resolution_1d * 4)
+ for c in range(lut_resolution_1d):
+ data[c] = transfer_function(c / (lut_resolution_1d - 1))
+
+ # Write the sampled data to a LUT
+ lut = '%s_to_linear.spi1d' % transfer_function_name
+ genlut.write_SPI_1d(
+ os.path.join(lut_directory, lut),
+ 0,
+ 1,
+ data,
+ lut_resolution_1d,
+ 1)
+
+ # Create the 'to_reference' transforms
+ cs.to_reference_transforms = []
+ cs.to_reference_transforms.append({
+ 'type': 'lutFile',
+ 'path': lut,
+ 'interpolation': 'linear',
+ 'direction': 'forward'})
+
+ # Create the 'from_reference' transforms
+ cs.from_reference_transforms = []
+
+ return cs
+# create_transfer_colorspace
+
+# -------------------------------------------------------------------------
+# *Transfer Function + Matrix Transform*