# Path: Lib/glyphsLib/builder/common.py
# def to_ufo_color(color):
#     if isinstance(color, str):
#         color = [int(v) for v in color.split(",")]
#     if len(color) == 2:
#         # Greyscale color
#         color = (color[0], color[0], color[0], color[1])
#     elif len(color) == 5:
#         # CMYK color
#         raise NotImplementedError("CMYK colors are not supported")
#     return tuple(c / 255 for c in color)
# 
# Path: Lib/glyphsLib/builder/constants.py
# UFO2FT_COLOR_LAYERS_KEY = "com.github.googlei18n.ufo2ft.colorLayers"
# 
# UFO2FT_COLOR_PALETTES_KEY = "com.github.googlei18n.ufo2ft.colorPalettes"


import math
        import pathops
from fontTools.misc.transform import Identity, Transform
from fontTools.ttLib.tables.otTables import PaintFormat
from .common import to_ufo_color
from .constants import UFO2FT_COLOR_LAYERS_KEY, UFO2FT_COLOR_PALETTES_KEY
            f"'pathops' module."
        ) from ex

    pos = attributes.get("strokePos", 0)
    if pos:
        raise NotImplementedError(
            f"Unsupported color layer path attribute 'strokePos' "
            f"in '{layer.parent.name}'"
        )

    width = attributes.get("strokeWidth", 1)
    path = pathops.Path()
    ufo_glyph.draw(path.getPen(glyphSet=ufo))
    path.stroke(width, pathops.LineCap.BUTT_CAP, pathops.LineJoin.MITER_JOIN, 4)
    ufo_glyph.clear()
    path.draw(ufo_glyph.getPen())

    color = attributes.get("strokeColor")
    paletteIndex, a = _find_or_insert_color(color, palette)
    return dict(Format=PaintFormat.PaintSolid, Alpha=a, PaletteIndex=paletteIndex)


def _to_component_paint(component):
    paint = dict(Format=PaintFormat.PaintColrGlyph, Glyph=component.name)
    t = Transform(*component.transform)
    if t != Identity:
        if t[:4] == (1, 0, 0, 1):
            return dict(
                Format=PaintFormat.PaintTranslate, Paint=paint, dx=t.dx, dy=t.dy
            )

# Path: Lib/glyphsLib/builder/common.py
# def to_ufo_color(color):
#     if isinstance(color, str):
#         color = [int(v) for v in color.split(",")]
#     if len(color) == 2:
#         # Greyscale color
#         color = (color[0], color[0], color[0], color[1])
#     elif len(color) == 5:
#         # CMYK color
#         raise NotImplementedError("CMYK colors are not supported")
#     return tuple(c / 255 for c in color)
# 
# Path: Lib/glyphsLib/builder/constants.py
# UFO2FT_COLOR_LAYERS_KEY = "com.github.googlei18n.ufo2ft.colorLayers"
# 
# UFO2FT_COLOR_PALETTES_KEY = "com.github.googlei18n.ufo2ft.colorPalettes"


# Path: Lib/glyphsLib/builder/color_layers.py
import math
        import pathops
from fontTools.misc.transform import Identity, Transform
from fontTools.ttLib.tables.otTables import PaintFormat
from .common import to_ufo_color
from .constants import UFO2FT_COLOR_LAYERS_KEY, UFO2FT_COLOR_PALETTES_KEY

            f"'pathops' module."
        ) from ex

    pos = attributes.get("strokePos", 0)
    if pos:
        raise NotImplementedError(
            f"Unsupported color layer path attribute 'strokePos' "
            f"in '{layer.parent.name}'"
        )

    width = attributes.get("strokeWidth", 1)
    path = pathops.Path()
    ufo_glyph.draw(path.getPen(glyphSet=ufo))
    path.stroke(width, pathops.LineCap.BUTT_CAP, pathops.LineJoin.MITER_JOIN, 4)
    ufo_glyph.clear()
    path.draw(ufo_glyph.getPen())

    color = attributes.get("strokeColor")
    paletteIndex, a = _find_or_insert_color(color, palette)
    return dict(Format=PaintFormat.PaintSolid, Alpha=a, PaletteIndex=paletteIndex)


def _to_component_paint(component):
    paint = dict(Format=PaintFormat.PaintColrGlyph, Glyph=component.name)
    t = Transform(*component.transform)
    if t != Identity:
        if t[:4] == (1, 0, 0, 1):
            return dict(
                Format=PaintFormat.PaintTranslate, Paint=paint, dx=t.dx, dy=t.dy
            )

        else: