code: def __init__(self, content, mode="x", parent=None):
      if not content:
          self._unit = None
          self._value = 0
          self._computed_value = 0
          return
  
      re_number = r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?"
      re_unit = r"em|ex|px|in|cm|mm|pt|pc|%"
      re_length = r"(?P<value>%s)\s*(?P<unit>%s)*" % (
          re_number,
          re_unit,
      )
      match = re.match(re_length, content)
  
      if match:
          self._value = float(match.group("value"))
          self._unit = match.group("unit") or "px"
      else:
          self._value = 0.0
          self._unit = None
  
      scale = 1
      if self._unit == "%":
          if not parent:
              logger.warn(
                  "No parent for computing length using percent"
              )
          elif hasattr(parent, "viewport"):
              w, h = parent.viewport
              if mode == "x":
                  scale = w
              elif mode == "y":
                  scale = h
              elif mode == "xy":
                  scale = math.sqrt(w * w + h * h) / math.sqrt(2.0)
          else:
              logger.warn("Parent doesn't have a viewport")
  
      self._computed_value = self._value * units[self._unit] * scale
  
file_path: vispy/vispy/util/svg/length.py
imports: import re
  import math
  from .base import units
  from ..None import logger
label_desc: Use image node_id 1 to create a new Length object from inherited base classes: object with example: obj = Length(content, mode, parent)