How to use the colorio._tools.get_mono_outline_xy function in colorio

To help you get started, we’ve selected a few colorio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / colorio / colorio / _color_space.py View on Github external
def plot_visible_slice(
        self, level, outline_prec=1.0e-2, plot_srgb_gamut=True, fill_color="0.8"
    ):
        # first plot the monochromatic outline
        mono_xy, conn_xy = get_mono_outline_xy(
            observer=cie_1931_2(), max_stepsize=outline_prec
        )

        mono_vals = numpy.array([self._bisect(xy, self.k0, level) for xy in mono_xy])
        conn_vals = numpy.array([self._bisect(xy, self.k0, level) for xy in conn_xy])

        k1, k2 = [k for k in [0, 1, 2] if k != self.k0]
        plt.plot(mono_vals[:, k1], mono_vals[:, k2], "-", color="k")
        plt.plot(conn_vals[:, k1], conn_vals[:, k2], ":", color="k")
        #
        if fill_color is not None:
            xyz = numpy.vstack([mono_vals, conn_vals[1:]])
            plt.fill(xyz[:, k1], xyz[:, k2], facecolor=fill_color, zorder=0)

        if plot_srgb_gamut:
            self._plot_srgb_gamut(self.k0, level)
github nschloe / colorio / colorio / _color_space.py View on Github external
def save_cone_gamut(self, filename, observer, max_Y):
        import meshio
        import pygmsh

        geom = pygmsh.built_in.Geometry()

        max_stepsize = 4.0e-2
        xy, _ = get_mono_outline_xy(observer, max_stepsize=max_stepsize)

        # append third component
        xy = numpy.column_stack([xy, numpy.full(xy.shape[0], 1.0e-5)])

        # Draw a cross.
        poly = geom.add_polygon(xy, lcar=max_stepsize)

        axis = [0, 0, max_Y]

        geom.extrude(poly, translation_axis=axis, point_on_axis=[0, 0, 0])

        mesh = pygmsh.generate_mesh(geom, verbose=False)
        # meshio.write(filename, mesh)

        pts = self.from_xyz100(_xyy_to_xyz100(mesh.points.T)).T
        meshio.write_points_cells(