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:
ExportOptionsBaseConfiguration for GLSL source-code palette export.
- Variables:
representation (
Literal['array','constants','defines']) –"array"emits one indexed constant array,"constants"emits namedconstvalues, 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.0suffix.include_alpha (
bool) – Emitvec4values with an opaque alpha channel instead ofvec3values.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>_SIZEwith the number of colors.include_version (
bool) – Emit a#versiondirective as the first line.version (
str) – Version directive value, such as"330 core"or"300 es".
- Parameters:
- class color_tools.exporters.glsl_exporter.GLSLExporter[source]
Bases:
PaletteExporterExport palettes as reusable GLSL
vec3orvec4definitions.- property metadata: ExporterMetadata
Return metadata describing the GLSL exporter.