Cosplay/nhf/materials.py

41 lines
1.1 KiB
Python
Raw Normal View History

2024-06-26 06:48:32 -07:00
"""
A catalog of material properties
"""
from enum import Enum
import cadquery as Cq
def _color(name: str, alpha: float) -> Cq.Color:
r, g, b, _ = Cq.Color(name).toTuple()
return Cq.Color(r, g, b, alpha)
2024-06-27 20:26:21 -07:00
class Role(Enum):
"""
Describes the role of a part
"""
# Parent and child components in a load bearing joint
PARENT = _color('blue4', 0.6)
CHILD = _color('darkorange2', 0.6)
DAMPING = _color('springgreen', 0.5)
2024-06-27 20:26:21 -07:00
STRUCTURE = _color('gray', 0.4)
DECORATION = _color('lightseagreen', 0.4)
ELECTRONIC = _color('mediumorchid', 0.5)
def __init__(self, color: Cq.Color):
self.color = color
2024-06-26 06:48:32 -07:00
class Material(Enum):
2024-06-27 20:26:21 -07:00
"""
A catalog of common material properties
"""
2024-06-26 06:48:32 -07:00
WOOD_BIRCH = 0.8, _color('bisque', 0.9)
PLASTIC_PLA = 0.5, _color('azure3', 0.6)
RESIN_TRANSPARENT = 1.1, _color('cadetblue2', 0.6)
2024-06-26 06:48:32 -07:00
ACRYLIC_BLACK = 0.5, _color('gray50', 0.6)
2024-07-07 21:01:40 -07:00
ACRYLIC_TRANSPARENT = 0.5, _color('ghostwhite', 0.5)
2024-06-26 06:48:32 -07:00
def __init__(self, density: float, color: Cq.Color):
self.density = density
self.color = color