class_docstr: Represents a color in terms of float values for RGBA between 0.0 and 1.0.
class_docstr_tok: ["Represents","a","color","in","terms","of","float","values","for","RGBA","between","0.0","and","1.0","."]
docstr: Create a Color instance from a hex string like #ffaa22 or #11aa88ff.
  
  Supports both long and short form (i.e. #ffffff is the same as #fff), and also an optional
  alpha value (e.g. #112233ff or #123f).
docstr_tok: ["Create","a","Color","instance","from","a","hex","string","like","#","ffaa22","or","#","11aa88ff",".","Supports","both","long","and","short","form","(","i.e",".","#","ffffff","is","the","same","as","#","fff",")",",","and","also","an","optional","alpha","value","(","e.g",".","#","112233ff","or","#","123f",")","."]
code: def from_hexstr(cls, hexstr: str):
      """Create a Color instance from a hex string like #ffaa22 or #11aa88ff.
  
      Supports both long and short form (i.e. #ffffff is the same as #fff), and also an optional
      alpha value (e.g. #112233ff or #123f).
      """
      if hexstr[0] == "#":  # get rid of leading #
          hexstr = hexstr[1:]
      if len(hexstr) == 3:
          r = int(hexstr[0], 16) / 15.0
          g = int(hexstr[1], 16) / 15.0
          b = int(hexstr[2], 16) / 15.0
          return cls(r, g, b)
      elif len(hexstr) == 4:
          r = int(hexstr[0], 16) / 15.0
          g = int(hexstr[1], 16) / 15.0
          b = int(hexstr[2], 16) / 15.0
          a = int(hexstr[3], 16) / 15.0
          return cls(r, g, b, a)
      elif len(hexstr) == 6:
          r = int(hexstr[0:2], 16) / 255.0
          g = int(hexstr[2:4], 16) / 255.0
          b = int(hexstr[4:6], 16) / 255.0
          return cls(r, g, b)
      elif len(hexstr) == 8:
          r = int(hexstr[0:2], 16) / 255.0
          g = int(hexstr[2:4], 16) / 255.0
          b = int(hexstr[4:6], 16) / 255.0
          a = int(hexstr[6:8], 16) / 255.0
          return cls(r, g, b, a)
      else:
          raise ValueError("invalid color hex string")
  
file_path: kubric/kubric/core/color.py
imports: import colorsys
  from typing import NamedTuple, Tuple, Union
label_desc: Use image node_id 7 for calling the Color obj's underlying member method code with example usage: obj.from_hexstr(cls, hexstr) and returns: cls, cls, cls, cls