INNER CODE UNIT · Python

corners

WenyuChiou/awesome-agentic-ai-zh · scripts/build-role-map.py:116

            corners = [source.getpixel(p) for p in ((x,y), (x+w-1,y), (x,y+h-1), (x+w-1,y+h-1))]
            paper = "#" + "".join(f"{int(median(c)):02x}" for c in zip(*corners))
            cx, cy = x+w/2, y+h if role == "knowledge" else y+h/2
            parts.append(f'<g id="role-{role}" class="role-layer role-{role}" aria-hidden="true">'
                f'<defs><clipPath id="clip-{role}"><rect x="{x}" y="{y}" width="{w}" height="{h}"/></clipPath></defs>'
                f'<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{paper}"/>'
                f'<g transform="translate({cx} {cy})"><g class="role-motion move-{role}">'
                f'<g transform="translate({-cx} {-cy})" clip-path="url(#clip-{role})"><use href="#original-art"/></g>'
                '</g></g></g>')
    return "\n".join(parts + ["</svg>"]) + "\n"


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--locale", choices=LOCALES)
    parser.add_argument("--import-original", action="store_true")
    parser.add_argument("--png", action="store_true")
    parser.add_argument("--check", action="store_true")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…