def transparency(self) -> float: try: xdata = self.get_xdata(AcCmTransparency) except DXFValueError: return 0 else: return clr.transparency2float(xdata[0].value)
def transparency(self) -> float: """ Get transparency as float value between 0 and 1, 0 is opaque and 1 is 100% transparent (invisible). """ if self.dxf.hasattr('transparency'): return clr.transparency2float(self.dxf.get('transparency')) else: return 0.
def transparency(self) -> float: try: xdata = self.get_xdata(AcCmTransparency) except DXFValueError: return 0.0 else: t = xdata[0].value if t & 0x2000000: # is this a real transparency value? # Transparency BYBLOCK (0x01000000) make no sense for a layer!? return clr.transparency2float(t) return 0.0
def transparency(self) -> float: """Get transparency as float value between 0 and 1, 0 is opaque and 1 is 100% transparent (invisible). Transparency by block returns always 0. """ if self.dxf.hasattr("transparency"): value = self.dxf.get("transparency") if validator.is_transparency(value): if value & TRANSPARENCY_BYBLOCK: # just check flag state return 0.0 return clr.transparency2float(value) return 0.0
def from_entity(cls, entity: "DXFEntity") -> "GfxAttribs": """Get the graphical attributes of an `entity` as :class:`GfxAttribs` object. """ attribs = cls() dxf = entity.dxf for name in ["layer", "color", "linetype", "lineweight", "ltscale"]: if dxf.hasattr(name): setattr(attribs, name, dxf.get(name)) if dxf.hasattr("true_color"): attribs.rgb = colors.int2rgb(dxf.true_color) if dxf.hasattr("transparency"): if dxf.transparency == colors.TRANSPARENCY_BYBLOCK: attribs.transparency = TRANSPARENCY_BYBLOCK else: attribs.transparency = colors.transparency2float( dxf.transparency ) return attribs
def test_transparency_to_float(t_int, t_float): assert round(colors.transparency2float(t_int), 2) == t_float