aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2019-05-08 13:24:26 +0200
committerThomas Touhey <thomas@touhey.fr>2019-05-08 13:24:26 +0200
commitb98bdc087c25ba9ed8b625af39c756bf4ec3b48c (patch)
tree6a0e49421b07e1837daaa42cf218c0359bf07ac6
parent19e0f4fda89731ff6700acce8f3a2ed48a8b94b5 (diff)
Added hsl (with hue and angle support)
-rw-r--r--setup.cfg2
-rwxr-xr-xthcolor/__init__.py9
-rwxr-xr-xthcolor/_angle.py211
-rwxr-xr-xthcolor/_builtin/__init__.py3
-rwxr-xr-xthcolor/_builtin/_css.py102
-rwxr-xr-xthcolor/_builtin/_default.py87
-rwxr-xr-xthcolor/_color.py72
-rwxr-xr-x[-rw-r--r--]thcolor/_exc.py0
-rwxr-xr-x[-rw-r--r--]thcolor/_ref.py55
9 files changed, 452 insertions, 89 deletions
diff --git a/setup.cfg b/setup.cfg
index 0d40bd7..5096ffd 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = thcolor
-version = 0.2.1
+version = attr: thcolor.version
url = https://thcolor.touhey.pro/
author = Thomas Touhey
author_email = thomas@touhey.fr
diff --git a/thcolor/__init__.py b/thcolor/__init__.py
index 4bb479d..850f411 100755
--- a/thcolor/__init__.py
+++ b/thcolor/__init__.py
@@ -12,13 +12,16 @@
from ._color import Color
from ._ref import Reference
+from ._angle import Angle
+
from ._exc import ColorExpressionDecodingError
from ._builtin import (CSS1Reference, CSS2Reference, CSS3Reference,
- CSS4Reference)
+ CSS4Reference, DefaultReference)
-__all__ = ["version", "Color", "Reference", "ColorExpressionDecodingError",
+__all__ = ["version", "Color", "Reference", "Angle",
+ "ColorExpressionDecodingError",
"CSS1Reference", "CSS2Reference", "CSS3Reference",
- "CSS4Reference"]
+ "CSS4Reference", "DefaultReference"]
version = "0.2.1"
diff --git a/thcolor/_angle.py b/thcolor/_angle.py
new file mode 100755
index 0000000..0a0b1bd
--- /dev/null
+++ b/thcolor/_angle.py
@@ -0,0 +1,211 @@
+#!/usr/bin/env python3
+#******************************************************************************
+# Copyright (C) 2019 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
+# This file is part of the thcolor project, which is MIT-licensed.
+#******************************************************************************
+""" Angle management. """
+
+from math import pi as _pi
+from enum import Enum as _Enum
+
+__all__ = ["Angle"]
+
+def _deg(name, value):
+ value = float(value)
+ return value # % 360.0
+
+def _grad(name, value):
+ value = float(value)
+ return value # % 400.0
+
+def _rad(name, value):
+ value = float(value)
+ return value # % (2 * _pi)
+
+def _turn(name, value):
+ value = float(value)
+ return value # % 1
+
+# ---
+# Angle definition.
+# ---
+
+class _AngleType(_Enum):
+ """ The angle unit type. """
+
+ """ Invalid angle. """
+ INVALID = 0
+
+ """ Degrees (360 degrees in a full circle). """
+ DEG = 1
+
+ """ Gradiants (400 gradiants in a full circle). """
+ GRAD = 2
+
+ """ Radiants (2π radiants in a full circle). """
+ RAD = 3
+
+ """ Turns (1 turn in a full circle). """
+ TURN = 4
+
+class Angle:
+ """ Represent an angle with all of its available formats. """
+
+ # Properties to work with:
+ #
+ # `_type`: the type as one of the `Angle.Type` constants.
+ # `_value`: the angle value.
+
+ Type = _AngleType
+
+ def __init__(self, *args, **kwargs):
+ self._type = Angle.Type.INVALID
+ self.set(*args, **kwargs)
+
+ def __repr__(self):
+ args = (('type', self._type),)
+ if self._type in (Angle.Type.DEG, Angle.Type.GRAD, Angle.Type.RAD,
+ Angle.Type.TURN):
+ args += (('value', self._value),)
+
+ argtext = ', '.join(f'{key}: {repr(value)}' for key, value in args)
+ return f"{self.__class__.__name__}({argtext})"
+
+ # ---
+ # Management methods.
+ # ---
+
+ def set(self, *args, **kwargs):
+ """ Set the angle. """
+
+ args = list(args)
+
+ def _decode_varargs(*keys):
+ # Check for each key.
+
+ results = ()
+
+ for names, convert_func, *value in keys:
+ for name in names:
+ if name in kwargs:
+ if args:
+ raise TypeError(f"{self.__class__.__name__}() " \
+ f"got multiple values for argument {name}")
+
+ raw_result = kwargs.pop(name)
+ break
+ else:
+ name = names[0]
+ if args:
+ raw_result = args.pop(0)
+ elif value:
+ raw_result = value[0] if len(value) == 1 else value
+ else:
+ raise TypeError(f"{self.__class__.__name__}() " \
+ "missing a required positional argument: " \
+ f"{name}")
+
+ result = convert_func(name, raw_result)
+ results += (result,)
+
+ # Check for keyword arguments for which keys are not in the set.
+
+ if kwargs:
+ raise TypeError(f"{next(iter(kwargs.keys()))} is an invalid " \
+ f"keyword argument for type {type}")
+
+ return results
+
+ # ---
+ # Main function body.
+ # ---
+
+ # Check for the type.
+
+ if args:
+ try:
+ type = kwargs.pop('type')
+ except:
+ type = args.pop(0)
+ else:
+ if isinstance(args[0], Color.Type):
+ raise TypeError(f"{self.__class__.__name__}() got " \
+ "multiple values for argument 'type'")
+ else:
+ try:
+ type = kwargs.pop('type')
+ except:
+ type = self._type
+ if type == Angle.Type.INVALID:
+ raise TypeError(f"{self.__class__.__name__}() missing " \
+ "required argument: 'type'")
+
+ try:
+ type = Angle.Type(type)
+ except:
+ type = Angle.Type.DEG
+
+ # Initialize the properties.
+
+ if type == Angle.Type.DEG:
+ self._value, = _decode_varargs(\
+ (('value', 'angle', 'degrees'), _deg))
+ elif type == Angle.Type.GRAD:
+ self._value, = _decode_varargs(\
+ (('value', 'angle', 'gradiants'), _grad))
+ elif type == Angle.Type.RAD:
+ self._value, = _decode_varargs(\
+ (('value', 'angle', 'radiants'), _rad))
+ elif type == Angle.Type.TURN:
+ self._value, = _decode_varargs(\
+ (('value', 'angle', 'turns'), _turn))
+ else:
+ raise ValueError(f"invalid color type: {type}")
+
+ # Once the arguments have been tested to be valid, we can set the
+ # type.
+
+ self._type = type
+
+ # ---
+ # Properties.
+ # ---
+
+ @property
+ def type(self):
+ """ Get the type. """
+
+ return self._type
+
+ @property
+ def degrees(self):
+ """ Get the angle in degrees. """
+
+ return self.turns * 360
+
+ @property
+ def gradiants(self):
+ """ Get the angle in gradiants. """
+
+ return self.turns * 400
+
+ @property
+ def radiants(self):
+ """ Get the angle in radiants. """
+
+ return self.turns * (2 * _pi)
+
+ @property
+ def turns(self):
+ """ Get the angle in turns. """
+
+ if self._type == Angle.Type.DEG:
+ return self._value / 360
+ elif self._type == Angle.Type.GRAD:
+ return self._value / 400
+ elif self._type == Angle.Type.RAD:
+ return self._value / (2 * _pi)
+ elif self._type == Angle.Type.TURN:
+ return self._value
+
+# End of file.
diff --git a/thcolor/_builtin/__init__.py b/thcolor/_builtin/__init__.py
index 3b77cf3..c9bc0d2 100755
--- a/thcolor/_builtin/__init__.py
+++ b/thcolor/_builtin/__init__.py
@@ -7,8 +7,9 @@
from ._css import (CSS1Reference, CSS2Reference, CSS3Reference,
CSS4Reference)
+from ._default import DefaultReference
__all__ = ["CSS1Reference", "CSS2Reference", "CSS3Reference",
- "CSS4Reference"]
+ "CSS4Reference", "DefaultReference"]
# End of file.
diff --git a/thcolor/_builtin/_css.py b/thcolor/_builtin/_css.py
index 4981adc..a875907 100755
--- a/thcolor/_builtin/_css.py
+++ b/thcolor/_builtin/_css.py
@@ -283,13 +283,53 @@ class CSS4Reference(CSS3Reference):
h, s, l, alpha = hsla
hi, si, li = hsl_indexes
- raise NotImplementedError
+ try:
+ h = h.to_hue()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(hi, str(e))
+
+ try:
+ s = s.to_factor()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(si, str(e))
+
+ try:
+ l = l.to_factor()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(li, str(e))
+
+ try:
+ alpha = alpha.to_factor()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(3, str(e))
+
+ return _Reference.color(_Color(_Color.Type.HSL, h, s, l, alpha))
def _hwb(self, hwba, hwb_indexes):
h, w, b, alpha = hwba
hi, wi, bi = hwb_indexes
- raise NotImplementedError
+ try:
+ h = h.to_hue()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(hi, str(e))
+
+ try:
+ w = w.to_factor()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(wi, str(e))
+
+ try:
+ b = b.to_factor()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(bi, str(e))
+
+ try:
+ alpha = alpha.to_factor()
+ except ValueError as e:
+ raise _InvalidArgumentValueError(3, str(e))
+
+ return _Reference.color(_Color(_Color.Type.HWB, h, w, b, alpha))
# ---
# Functions.
@@ -305,56 +345,6 @@ class CSS4Reference(CSS3Reference):
alpha: number | percentage = number(1.0)):
return self._rgb((r, g, b, alpha), (0, 1, 2))
- def rbg(self, r: number | percentage,
- b: number | percentage = number(0), g: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (0, 2, 1))
-
- def rbga(self, r: number | percentage,
- b: number | percentage = number(0), g: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (0, 2, 1))
-
- def brg(self, b: number | percentage,
- r: number | percentage = number(0), g: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (1, 2, 0))
-
- def brga(self, b: number | percentage,
- r: number | percentage = number(0), g: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (1, 2, 0))
-
- def bgr(self, b: number | percentage,
- g: number | percentage = number(0), r: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (2, 1, 0))
-
- def bgra(self, b: number | percentage,
- g: number | percentage = number(0), r: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (2, 1, 0))
-
- def gbr(self, g: number | percentage,
- b: number | percentage = number(0), r: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (2, 0, 1))
-
- def gbra(self, g: number | percentage,
- b: number | percentage = number(0), r: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (2, 0, 1))
-
- def grb(self, g: number | percentage,
- r: number | percentage = number(0), b: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (1, 0, 2))
-
- def grba(self, g: number | percentage,
- r: number | percentage = number(0), b: number | percentage = number(0),
- alpha: number | percentage = number(1.0)):
- return self._rgb((r, g, b, alpha), (1, 0, 2))
-
def hsl(self, h: number | angle, s: number | percentage,
l: number | percentage, alpha: number | percentage = number(1.0)):
return self._hsl((h, s, l, alpha), (0, 1, 2))
@@ -363,14 +353,6 @@ class CSS4Reference(CSS3Reference):
l: number | percentage, alpha: number | percentage = number(1.0)):
return self._hsl((h, s, l, alpha), (0, 1, 2))
- def hls(self, h: number | angle, l: number | percentage,
- s: number | percentage, alpha: number | percentage = number(1.0)):
- return self._hsl((h, s, l, alpha), (0, 2, 1))
-
- def hlsa(self, h: number | angle, l: number | percentage,
- s: number | percentage, alpha: number | percentage = number(1.0)):
- return self._hsl((h, s, l, alpha), (0, 2, 1))
-
def hwb(self, h: number | angle, w: number | percentage,
b: number | percentage, alpha: number | percentage = number(1.0)):
return self._hwb((h, w, b, alpha), (0, 1, 2))
diff --git a/thcolor/_builtin/_default.py b/thcolor/_builtin/_default.py
new file mode 100755
index 0000000..d6004be
--- /dev/null
+++ b/thcolor/_builtin/_default.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python3
+#******************************************************************************
+# Copyright (C) 2019 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
+# This file is part of the thcolor project, which is MIT-licensed.
+#******************************************************************************
+""" Named colors and function definitions. Color names are case-insensitive.
+ Extends the CSS references. """
+
+from .._ref import Reference as _Reference
+from ._css import CSS4Reference as _CSS4Reference
+
+__all__ = ["DefaultReference"]
+
+class DefaultReference(_CSS4Reference):
+ """ Extensions to the CSS Color Module Level 4 reference. """
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ number = _Reference.number
+ percentage = _Reference.percentage
+ angle = _Reference.angle
+ color = _Reference.color
+
+ # ---
+ # Utilities.
+ # ---
+
+ def rbg(self, r: number | percentage,
+ b: number | percentage = number(0), g: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (0, 2, 1))
+
+ def rbga(self, r: number | percentage,
+ b: number | percentage = number(0), g: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (0, 2, 1))
+
+ def brg(self, b: number | percentage,
+ r: number | percentage = number(0), g: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (1, 2, 0))
+
+ def brga(self, b: number | percentage,
+ r: number | percentage = number(0), g: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (1, 2, 0))
+
+ def bgr(self, b: number | percentage,
+ g: number | percentage = number(0), r: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (2, 1, 0))
+
+ def bgra(self, b: number | percentage,
+ g: number | percentage = number(0), r: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (2, 1, 0))
+
+ def gbr(self, g: number | percentage,
+ b: number | percentage = number(0), r: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (2, 0, 1))
+
+ def gbra(self, g: number | percentage,
+ b: number | percentage = number(0), r: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (2, 0, 1))
+
+ def grb(self, g: number | percentage,
+ r: number | percentage = number(0), b: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (1, 0, 2))
+
+ def grba(self, g: number | percentage,
+ r: number | percentage = number(0), b: number | percentage = number(0),
+ alpha: number | percentage = number(1.0)):
+ return self._rgb((r, g, b, alpha), (1, 0, 2))
+
+ def hls(self, h: number | angle, l: number | percentage,
+ s: number | percentage, alpha: number | percentage = number(1.0)):
+ return self._hsl((h, s, l, alpha), (0, 2, 1))
+
+ def hlsa(self, h: number | angle, l: number | percentage,
+ s: number | percentage, alpha: number | percentage = number(1.0)):
+ return self._hsl((h, s, l, alpha), (0, 2, 1))
+
+# End of file.
diff --git a/thcolor/_color.py b/thcolor/_color.py
index a300608..76dc505 100755
--- a/thcolor/_color.py
+++ b/thcolor/_color.py
@@ -4,14 +4,14 @@
# This file is part of the thcolor project, which is MIT-licensed.
#******************************************************************************
""" HTML/CSS like color parsing, mainly for the `[color]` tag.
- Defines the `get_color()` function which returns an rgba value.
-"""
+ Defines the `get_color()` function which returns an rgba value. """
import regex as _re
from enum import Enum as _Enum
from ._ref import Reference as _Reference
+from ._angle import Angle as _Angle
from ._sys import (hls_to_rgb as _hls_to_rgb, hwb_to_rgb as _hwb_to_rgb,
netscape_color as _netscape_color)
from ._exc import (\
@@ -66,7 +66,15 @@ def _percentage(name, value):
return value
def _hue(name, value):
- raise ValueError(f"{name} is not a valid hue") from None
+ if isinstance(value, _Angle):
+ pass
+ else:
+ try:
+ value = _Angle(value)
+ except:
+ raise ValueError(f"{name} should be an Angle instance")
+
+ return value
# ---
# Color class definition.
@@ -92,7 +100,7 @@ class Color:
# Properties to work with:
#
- # `_type`: the type as one of the Color.Type constants.
+ # `_type`: the type as one of the `Color.Type` constants.
# `_alpha`: alpha value.
# `_r`, `_g`, `_b`: rgb components, as bytes.
# `_hue`: hue for HSL and HWB notations.
@@ -204,7 +212,7 @@ class Color:
(('b', 'blue'), _byte),
(('a', 'alpha'), _percentage, 1.0))
elif type == Color.Type.HSL:
- self._hue, self._sat, self._lig, self._alpha = _decode_varargs(\
+ self._hue, self._sat, self._lgt, self._alpha = _decode_varargs(\
(('h', 'hue'), _hue),
(('s', 'sat', 'saturation'), _percentage),
(('l', 'lig', 'light', 'lightness'), _percentage),
@@ -228,6 +236,12 @@ class Color:
# ---
@property
+ def type(self):
+ """ Get the type. """
+
+ return self._type
+
+ @property
def alpha(self):
""" Get the alpha. """
@@ -288,10 +302,16 @@ class Color:
if self._type == Color.Type.RGB:
return (self._r, self._g, self._b)
elif self._type == Color.Type.HSL:
- r, g, b = _hls_to_rgb(self._hue, self._lgt, self._sat)
+ r, g, b = _hls_to_rgb(self._hue.turns % 1, self._lgt, self._sat)
+ r *= 255
+ g *= 255
+ b *= 255
return (r, g, b)
elif self._type == Color.Type.HWB:
- r, g, b = _hwb_to_rgb(self._hue, self._wht, self._blk)
+ r, g, b = _hwb_to_rgb(self._hue.turns % 1, self._wht, self._blk)
+ r *= 255
+ g *= 255
+ b *= 255
return (r, g, b)
raise ValueError(f"color type {self._type} doesn't translate to rgb")
@@ -304,6 +324,34 @@ class Color:
return (r, g, b, alpha)
+ def css(self):
+ """ Get the CSS declarations (with compatibility management). """
+
+ def statements():
+ # Start by yelling a #RRGGBB color, compatible with most
+ # web browsers around the world, followed by the rgba()
+ # notation if the alpha value isn't 1.0.
+
+ r, g, b, a = self.rgba()
+ yield f'#{r:02X}{g:02X}{b:02X}'
+
+ if a < 1.0:
+ yield f'rgba({r}, {g}, {b}, {round(a, 3) * 100}%)'
+
+ # Then yield more specific CSS declarations in case
+ # they're supported (which would be neat!).
+
+ if self._type == Type.HSL:
+ s = round(self._sat, 5) * 100
+ l = round(self._lgt, 5) * 100
+ yield f'hsl({self._hue}, {s}%, {l}%)'
+ elif self._type == Type.HWB:
+ w = round(self._wht, 5) * 100
+ b = round(self._blk, 5) * 100
+ yield f'hwb({self._hue}, {w}%, {b}%)'
+
+ return list(statements())
+
# ---
# Static methods for decoding.
# ---
@@ -350,8 +398,14 @@ class Color:
if match['agl_val'] is not None:
# The matched value is an angle.
- value = _Reference.angle(float(match['agl_val']),
- match['agl_typ'])
+ agl_typ = {
+ 'deg': _Angle.Type.DEG,
+ 'grad': _Angle.Type.GRAD,
+ 'rad': _Angle.Type.RAD,
+ 'turn': _Angle.Type.TURN}[match['agl_typ']]
+
+ value = _Reference.angle(_Angle(agl_typ,
+ float(match['agl_val'])))
elif match['per'] is not None:
# The matched value is a percentage.
diff --git a/thcolor/_exc.py b/thcolor/_exc.py
index 1d858f2..1d858f2 100644..100755
--- a/thcolor/_exc.py
+++ b/thcolor/_exc.py
diff --git a/thcolor/_ref.py b/thcolor/_ref.py
index b224b52..5bc51c1 100644..100755
--- a/thcolor/_ref.py
+++ b/thcolor/_ref.py
@@ -9,6 +9,7 @@ from inspect import (getfullargspec as _getfullargspec,
getmembers as _getmembers, ismethod as _ismethod)
from itertools import count as _count
+from ._angle import Angle as _Angle
from ._sys import netscape_color as _netscape_color
from ._exc import (NotEnoughArgumentsError as _NotEnoughArgumentsError,
TooManyArgumentsError as _TooManyArgumentsError,
@@ -131,6 +132,9 @@ class Reference:
Color = _get_color_class()
return Color(Color.Type.RGB, r, g, b, 1.0)
+ def to_hue(self):
+ return _Angle(_Angle.Type.DEG, self._value)
+
class percentage(metaclass = base_type):
def __init__(self, value):
self._value = value
@@ -153,17 +157,17 @@ class Reference:
return self._value / 100
class angle(metaclass = base_type):
- def __init__(self, value, unit):
- self._value = value % 360.0
-
- self._unit = unit
- if not self._unit:
- self._unit = 'deg'
+ def __init__(self, value):
+ if not isinstance(value, _Angle):
+ raise TypeError("expected an Angle instance")
- assert self._unit in ('deg', 'grad', 'rad', 'turn')
+ self._value = value
def __repr__(self):
- return f"{self._value} {self._unit}"
+ return repr(self._value)
+
+ def to_hue(self):
+ return self._value
class color(metaclass = base_type):
def __init__(self, value):
@@ -244,11 +248,32 @@ class Reference:
arg_types = self._args \
+ self._optargs[:len(args) - len(self._args)]
-
- for index, arg, exp in zip(_count(), args, arg_types):
- if exp is not None and type(arg) not in exp:
- raise _InvalidArgumentTypeError(index,
- exp, type(arg), self._name)
+ arg_source = args
+ args = []
+
+ lit = zip(_count(), arg_source, arg_types)
+ for index, arg, exp in lit:
+ args.append(arg)
+ if exp is None:
+ continue
+ if type(arg) in exp:
+ continue
+
+ # If we haven't got a color but a color is one
+ # of the accepted types, try to transform into
+ # a color to manage number colors using the
+ # Netscape transformation such as '123'.
+
+ if color in exp:
+ try:
+ args[-1] = arg.to_color()
+ except:
+ pass
+ else:
+ continue
+
+ raise _InvalidArgumentTypeError(index,
+ exp, type(arg), self._name)
return self._func(*args)
@@ -288,8 +313,8 @@ class Reference:
if _default_reference is not None:
return _default_reference
- from ._builtin import CSS4Reference
- _default_reference = CSS4Reference()
+ from ._builtin import DefaultReference
+ _default_reference = DefaultReference()
return _default_reference
# End of file.