Skip to content

colour-science/colour-visuals

Colour - Visuals

Develop Build Status Coverage Status Code Grade Package Version

A Python package implementing various WebGPU-based visuals on top of pygfx for colour science applications.

It is open source and freely available under the BSD-3-Clause terms.

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Visuals_001.png

1   Features

Most of the objects are available from the colour_visuals namespace:

import colour_visuals

1.1   Examples

import colour_visuals
import numpy as np
import pygfx as gfx
from wgpu.gui.auto import WgpuCanvas, run

canvas = WgpuCanvas(size=(960, 540))
renderer = gfx.renderers.WgpuRenderer(canvas)
camera = gfx.PerspectiveCamera(50, 16 / 9)
controller = gfx.OrbitController(camera)
controller.register_events(renderer)

scene = gfx.Scene()
scene.add(gfx.Background(None, gfx.BackgroundMaterial(np.array([0.18, 0.18, 0.18]))))

visuals = [
    colour_visuals.VisualGrid(size=2),
    colour_visuals.VisualChromaticityDiagramCIE1931(
        kwargs_visual_chromaticity_diagram={"opacity": 0.25}
    ),
    colour_visuals.VisualRGBColourspace2D("ACEScg"),
    colour_visuals.VisualRGBColourspace2D(
        "Display P3", colour=np.array([0.5, 0.5, 0.5])
    ),
    colour_visuals.VisualRGBColourspace3D("Display P3", opacity=0.5, wireframe=True),
    colour_visuals.VisualRGBScatter3D(np.random.random([24, 32, 3]), "ACEScg"),
]

group = gfx.Group()
for visual in visuals:
    group.add(visual)

scene.add(group)

camera.local.position = np.array([-0.25, -0.5, 2])
camera.show_pos(np.array([1 / 3, 1 / 3, 0.4]))

canvas.request_draw(lambda: renderer.render(scene, camera))
run()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Visuals_002.png

import colour_visuals
import numpy as np
import pygfx as gfx
from wgpu.gui.auto import WgpuCanvas, run

canvas = WgpuCanvas(size=(960, 540))
renderer = gfx.renderers.WgpuRenderer(canvas)
camera = gfx.PerspectiveCamera(50, 16 / 9)
controller = gfx.OrbitController(camera)
controller.register_events(renderer)

scene = gfx.Scene()
scene.add(gfx.Background(None, gfx.BackgroundMaterial(np.array([0.18, 0.18, 0.18]))))

visuals = [
    colour_visuals.VisualGrid(size=4),
    colour_visuals.VisualSpectralLocus3D(model="CIE Lab"),
    colour_visuals.VisualPointerGamut3D(model="CIE Lab", colour=np.array([1, 0.5, 0])),
    colour_visuals.VisualRGBColourspace3D(
        "Display P3",
        model="CIE Lab",
        opacity=0.5,
        wireframe=True,
        segments=8,
    ),
    colour_visuals.VisualRGBScatter3D(
        np.random.random([24, 32, 3]), "Display P3", model="CIE Lab"
    ),
]

group = gfx.Group()
for visual in visuals:
    group.add(visual)

scene.add(group)

camera.local.position = np.array([1.5, -1.5, 5])
camera.show_pos(np.array([0, 0, 0.5]))

canvas.request_draw(lambda: renderer.render(scene, camera))
run()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Visuals_003.png

1.1.1   Daylight Locus Visuals

colour_visuals.Plotting_VisualDaylightLocus()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualDaylightLocus.png

1.1.2   Chromaticity Diagram Visuals

colour_visuals.Plotting_VisualSpectralLocus2D()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualSpectralLocus2D.png

colour_visuals.VisualChromaticityDiagramCIE1931(
    kwargs_visual_chromaticity_diagram={"opacity": 0.25}
)

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualChromaticityDiagramCIE1931.png

1.1.3   Planckian Locus Visuals

colour_visuals.VisualPlanckianLocus()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualPlanckianLocus.png

1.1.4   Pointer's Gamut Visuals

colour_visuals.VisualPointerGamut2D()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualPointerGamut2D.png

colour_visuals.VisualPointerGamut3D()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualPointerGamut3D.png

1.1.5   RGB Colourspace Visuals

colour_visuals.VisualRGBColourspace2D()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualRGBColourspace2D.png

colour_visuals.VisualRGBColourspace3D()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualRGBColourspace3D.png

1.1.6   RGB Scatter Visuals

colour_visuals.VisualRGBScatter3D(np.random.random([24, 32, 3]))

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualRGBScatter3D.png

1.1.7   Rösch-MacAdam Visuals

colour_visuals.VisualRoschMacAdam()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_VisualRoschMacAdam.png

1.1.8   Patterns

colour_visuals.pattern_hue_swatches()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_PatternHueSwatches.png

colour_visuals.pattern_hue_stripes()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_PatternHueStripes.png

colour_visuals.pattern_colour_wheel()

https://raw.githubusercontent.com/colour-science/colour-visuals/develop/docs/_static/Plotting_PatternColourWheel.png

2   User Guide

2.1   Installation

2.1.1   Primary Dependencies

2.1.2   Pypi

colour-visuals is not available on Pypi yet.

2.2   Contributing

If you would like to contribute to Colour - Visuals, please refer to the following Contributing guide for Colour.

3   API Reference

The main technical reference for Colour - Visuals is the API Reference.

4   Code of Conduct

The Code of Conduct, adapted from the Contributor Covenant 1.4, is available on the Code of Conduct page.

5   Contact & Social

The Colour Developers can be reached via different means:

6   About

Colour - Visuals by Colour Developers
Copyright 2023 Colour Developers – colour-developers@colour-science.org
This software is released under terms of BSD-3-Clause: https://opensource.org/licenses/BSD-3-Clause