Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.6

0.11.6 / src / tool_icons.luc

## Shared LuciaOS Rounded SVGs, rendered by luce-ui's cached luce-svg pipeline.
## Registry tools name their own icons (tool_registry.luc: the mesh tools and
## the CAD tools), as do the Edit kinds' own tools (EditTool.icon; a label
## that is a tool in two contexts draws the context's: actions.context_icon);
## this chain keeps the other names: nodes, commands, levels and categories.
## Original assets and extensions: Dy Mokomi, CC BY 4.0.
from luce_ui.ui import Painter
from luce_gpu.gpu import Color, Rect
from luce_ui import ui
from luce_geocore.geocore import Verbs
import tool_registry
import shader_nodes

pub func asset_name(name: str) -> str:
    # The registry's tools (the mesh verbs: Bevel, Loop Cut, …; the CAD
    # tools) name their own icons; a CAD tool of a mesh tool's label shares
    # its command and icon.
    let registered = tool_registry.icon_of(name)
    if registered != "": return registered
    # A verb that is no tool (Subdivision) may still name its icon.
    let verb = Verbs.index_of(name)
    if verb >= 0 and Verbs.icon(verb) != "": return Verbs.icon(verb)
    # The outliner's rows of a mesh's pieces.
    if name == "Cube": return "cube"
    if name == "Hulls": return "control-hulls"
    if name == "File": return "import"
    if name == "Export": return "export"
    if name == "Group": return "group"
    if name == "CAD": return "context-cad"
    if name == "Geo": return "mesh"
    if name == "SDF": return "context-sdf"
    if name == "Volumes": return "context-volume"
    if name == "GSplats": return "context-gsplats"
    if name == "Materials": return "material"
    if name == "Input": return "input-node"
    if name == "Import": return "import-stage"
    if name == "Surfaces": return "layer"
    if name == "Press Pull": return "press-pull"
    if name == "Camera": return "camera"
    if name == "Light": return "light-spot"
    if name == "Render": return "render"
    if name == "Material": return "material"
    if name == "Assign Material": return "assign-material"
    if name in ["Transform", "Move", "Transform Components"]: return "move-tool"
    if name == "Tessellate": return "tessellate"
    if name == "Blast": return "blast"
    if name == "Delete": return "trash"
    if name == "Edit Mesh": return "edit-mesh"
    if name == "Edit CAD": return "edit-cad"
    if name == "Edit SDF": return "edit-sdf"
    if name == "Edit GSplats": return "edit-gsplats"
    if name.starts_with("Edit "): return "pencil-tool"
    if name in ["Box", "Object"]: return "cube"
    if name == "Plane": return "plane"
    if name == "Merge": return "merge-geometry"
    if name == "Null": return "null-node"
    if name == "Output": return "output-node"
    if name == "Code": return "code"
    if name == "Script": return "script-node"
    if name == "Cache": return "cache-node"
    if name == "Switch": return "switch-node"
    if name == "Mirror": return "mirror-modifier"
    if name == "CopyTransform": return "array-modifier"
    if name == "CopyToPoints": return "copy-to-points"
    if name == "Normal": return "surface-normal"
    if name == "MatchSize": return "match-size"
    if name == "AttributeCreate": return "attribute-create"
    if name == "Name": return "name-attribute"
    if name == "AttributeRandomize": return "attribute-randomize"
    if name == "AttributeDelete": return "attribute-delete"
    if name == "AttributeRename": return "attribute-rename"
    if name == "AttributePromote": return "attribute-promote"
    if name in ["Selection", "Selection Group", "Select"]: return "selection-tool"
    if name == "Measure": return "measure-tool"
    if name == "UVProject": return "uv-project"
    if name == "Color": return "color-swatch"
    if name == "Rotate": return "rotate-tool"
    if name == "Scale": return "scale-tool"
    if name == "Pivot": return "pivot"
    if name == "Manipulator": return "transform-gizmo"
    if name == "Frame": return "frame-selection"
    # Edit SDF's capsule (its tools, like Edit GSplats', name their icons:
    # EditTool.icon).
    if name == "Capsule": return "capsule"
    # Shader nodes (Materials).
    if name == "Image Texture": return "image-texture"
    if name == "OpenPBR Surface": return "openpbr-surface"
    if shader_nodes.is_shader(name): return "shader-node"
    # luce-geocore's set verbs (curves, fields, volumes, splats) name no icon.
    if name == "Curve Line": return "line-tool"
    if name == "Curve Circle": return "circle-center"
    if name == "Curve Arc": return "arc-3-point"
    if name == "Curve Spiral": return "curve-spiral"
    if name == "Resample Curve": return "resample-curve"
    if name == "Trim Curve": return "trim-curve"
    if name == "Fillet Curve": return "sketch-fillet"
    if name == "Reverse Curve": return "reverse-curve"
    if name == "Set Curve Type": return "set-curve-type"
    if name == "Curve to Mesh": return "curve-to-mesh"
    if name == "Mesh to Curve": return "mesh-to-curve"
    if name.starts_with("SDF ") or name == "Mesh to SDF": return "context-sdf"
    if name == "Volume from Points": return "volume-from-points"
    if name == "Convert to Mesh": return "volume-to-mesh"
    if name == "Volume Slice": return "volume-slice"
    if name in ["Volume", "Volume Visualization"]: return "context-volume"
    if name == "Relight GSplats": return "gsplats-relight"
    if name == "Crop GSplats": return "gsplats-crop"
    if name == "Reduce GSplats": return "gsplats-reduce"
    if name == "GSplats Delete": return "trash"
    if name in ["Bake GSplats", "Delight GSplats", "GSplats SH Degree", "Clean GSplats", "GSplats from Polygons", "GSplats to Volume", "Normals from GSplats"]:
        return "context-gsplats"
    return "mesh"

pub func draw_icon(p: Painter, name: str, x: float, y: float, size: float, ink: Color) -> unit!:
    ui.draw_icon(p.target(), asset_name(name), Rect(x, y, size, size), ink)