# Generated by detroit
# See https://github.com/bourbonut/detroit/tree/main/api_maker

from functools import partial
from operator import is_not

class color:
    def __init__(self, content="color"):
        self.content = content

    def __repr__(self):
        return self.content

    def __str__(self):
        return self.content

    def __call__(self, *args):
        arguments = ", ".join(map(repr, args))
        return f"{self}({arguments})"

    def opacity(self):
        """
        .. code:: javascript

            d3.color("steelblue").opacity // 1

        This color’s opacity, typically in the range [0, 1].

        See more informations `here <https://d3js.org/d3-color#color_opacity>`_.
        """
        return color(content=f"{self.content}.opacity()")


    def rgb(self):
        """
        .. code:: javascript

            d3.color("hsl(120, 50%, 20%)").rgb() // {r: 25.5, g: 76.5, b: 25.5, opacity: 1}

        Source · Returns the RGB equivalent of this color. For RGB colors, that’s this.

        See more informations `here <https://d3js.org/d3-color#color_rgb>`_.
        """
        return color(content=f"{self.content}.rgb()")


    def copy(self, values=None):
        """
        .. code:: javascript

            d3.color("steelblue").copy({opacity: 0.5}) // {r: 70, g: 130, b: 180, opacity: 0.5}

        Source · Returns a copy of this color. If values is specified, any enumerable own
        properties of values are assigned to the new returned color.

        See more informations `here <https://d3js.org/d3-color#color_copy>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (values,))))
        return color(content=f"{self.content}.copy({arguments})")


    def brighter(self, k=None):
        """
        .. code:: javascript

            d3.color("steelblue").brighter(1) // {r: 100, g: 185.71428571428572, b: 257.14285714285717, opacity: 1}

        Source · Returns a brighter copy of this color. For example, if k is 1, steelblue in
        RGB color space becomes rgb(100, 186, 255). The parameter k controls how much brighter
        the returned color should be (in arbitrary units); if k is not specified, it defaults
        to 1. The behavior of this method is dependent on the implementing color space.

        See more informations `here <https://d3js.org/d3-color#color_brighter>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (k,))))
        return color(content=f"{self.content}.brighter({arguments})")


    def darker(self, k=None):
        """
        .. code:: javascript

            d3.color("steelblue").darker(1) // {r: 49, g: 91, b: 126, opacity: 1}

        Source · Returns a darker copy of this color. For example, if k is 1, steelblue in RGB
        color space becomes rgb(49, 91, 126). The parameter k controls how much darker the
        returned color should be (in arbitrary units); if k is not specified, it defaults to 1.
        The behavior of this method is dependent on the implementing color space.

        See more informations `here <https://d3js.org/d3-color#color_darker>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (k,))))
        return color(content=f"{self.content}.darker({arguments})")


    def displayable(self):
        """
        .. code:: javascript

            d3.color("steelblue").displayable(1) // true

        Source · Returns true if and only if the color is displayable on standard hardware. For
        example, this returns false for an RGB color if any channel value is less than zero or
        greater than 255 when rounded, or if the opacity is not in the range [0, 1].

        See more informations `here <https://d3js.org/d3-color#color_displayable>`_.
        """
        return color(content=f"{self.content}.displayable()")


    def formatHex(self):
        """
        .. code:: javascript

            d3.color("steelblue").formatHex() // "#4682b4"

        Source · Returns a hexadecimal string representing this color in RGB space, such as
        #4682b4. If this color is not displayable, a suitable displayable color is returned
        instead. For example, RGB channel values greater than 255 are clamped to 255.

        See more informations `here <https://d3js.org/d3-color#color_formatHex>`_.
        """
        return color(content=f"{self.content}.formatHex()")


    def formatHex8(self):
        """
        .. code:: javascript

            d3.color("steelblue").formatHex8() // "#4682b4ff"

        Source · Returns a hexadecimal string representing this color in RGBA space, such as
        #4682b4cc. If this color is not displayable, a suitable displayable color is returned
        instead. For example, RGB channel values greater than 255 are clamped to 255.

        See more informations `here <https://d3js.org/d3-color#color_formatHex8>`_.
        """
        return color(content=f"{self.content}.formatHex8()")


    def formatHsl(self):
        """
        .. code:: javascript

            d3.color("yellow").formatHsl() // "hsl(60, 100%, 50%)"

        Source · Returns a string representing this color according to the CSS Color Module
        Level 3 specification, such as hsl(257, 50%, 80%) or hsla(257, 50%, 80%, 0.2). If this
        color is not displayable, a suitable displayable color is returned instead by clamping
        S and L channel values to the interval [0, 100].

        See more informations `here <https://d3js.org/d3-color#color_formatHsl>`_.
        """
        return color(content=f"{self.content}.formatHsl()")


    def formatRgb(self):
        """
        .. code:: javascript

            d3.color("yellow").formatRgb() // "rgb(255, 255, 0)"

        Source · Returns a string representing this color according to the CSS Object Model
        specification, such as rgb(247, 234, 186) or rgba(247, 234, 186, 0.2). If this color is
        not displayable, a suitable displayable color is returned instead by clamping RGB
        channel values to the interval [0, 255].

        See more informations `here <https://d3js.org/d3-color#color_formatRgb>`_.
        """
        return color(content=f"{self.content}.formatRgb()")


    def toString(self):
        """
        .. code:: javascript

            d3.color("yellow").toString() // "rgb(255, 255, 0)"

        Source · An alias for color.formatRgb.

        See more informations `here <https://d3js.org/d3-color#color_toString>`_.
        """
        return color(content=f"{self.content}.toString()")

