color_tools.exporters.glsl_exporter

GLSL source-code palette exporter.

Exports ordered palettes as vec3 or vec4 shader definitions. Colors may be emitted as a constant array, named constants, or preprocessor defines. RGB channels are normalized to 0.0-1.0 by default; raw output preserves the 0-255 range while still emitting floating-point literals.

class color_tools.exporters.glsl_exporter.GLSLExportOptions(representation='array', normalized=True, include_alpha=False, include_metadata=True, include_names_as_comments=True, variable_name='PALETTE', identifier_prefix='', precision=6, include_size_constant=True, include_version=False, version='330 core')[source]

Bases: ExportOptionsBase

Configuration for GLSL source-code palette export.

Variables:
  • representation (Literal['array', 'constants', 'defines']) – "array" emits one indexed constant array, "constants" emits named const values, and "defines" emits named preprocessor definitions.

  • normalized (bool) – Divide RGB channels by 255 and emit values in the 0.0-1.0 range. When false, raw 0-255 channels are emitted with a .0 suffix.

  • include_alpha (bool) – Emit vec4 values with an opaque alpha channel instead of vec3 values.

  • include_metadata (bool) – Include available palette metadata as leading line comments.

  • include_names_as_comments (bool) – Add color names after entries in the array representation.

  • variable_name (str) – GLSL identifier used for the array and its optional size constant.

  • identifier_prefix (str) – Prefix applied to generated constant and macro identifiers.

  • precision (int) – Decimal places used for normalized channels. Must be at least one.

  • include_size_constant (bool) – Emit <variable_name>_SIZE with the number of colors.

  • include_version (bool) – Emit a #version directive as the first line.

  • version (str) – Version directive value, such as "330 core" or "300 es".

Parameters:
  • representation (Literal['array', 'constants', 'defines'])

  • normalized (bool)

  • include_alpha (bool)

  • include_metadata (bool)

  • include_names_as_comments (bool)

  • variable_name (str)

  • identifier_prefix (str)

  • precision (int)

  • include_size_constant (bool)

  • include_version (bool)

  • version (str)

representation: Literal['array', 'constants', 'defines']
normalized: bool
include_alpha: bool
include_metadata: bool
include_names_as_comments: bool
variable_name: str
identifier_prefix: str
precision: int
include_size_constant: bool
include_version: bool
version: str
__post_init__()[source]

Validate GLSL export options.

Return type:

None

class color_tools.exporters.glsl_exporter.GLSLExporter[source]

Bases: PaletteExporter

Export palettes as reusable GLSL vec3 or vec4 definitions.

property metadata: ExporterMetadata

Return metadata describing the GLSL exporter.