class_docstr: Visual subclass displaying a colorbar
  
  Parameters
  ----------
  cmap : str | vispy.color.ColorMap
      Either the name of the ColorMap to be used from the standard
      set of names (refer to `vispy.color.get_colormap`),
      or a custom ColorMap object.
      The ColorMap is used to apply a gradient on the colorbar.
  orientation : {'left', 'right', 'top', 'bottom'}
      The orientation of the colorbar, used for rendering. The
      orientation can be thought of as the position of the label
      relative to the color bar.
  
      When the orientation is 'left' or 'right', the colorbar is
      vertically placed. When it is 'top' or 'bottom', the colorbar is
      horizontally placed.
  
          * 'top': the colorbar is horizontal.
            Color is applied from left to right.
            Minimum corresponds to left and maximum to right.
            Label is to the top of the colorbar
  
          * 'bottom': Same as top, except that
            label is to the bottom of the colorbar
  
          * 'left': the colorbar is vertical.
            Color is applied from bottom to top.
            Minimum corresponds to bottom and maximum to top.
            Label is to the left of the colorbar
  
          * 'right': Same as left, except that the
            label is placed to the right of the colorbar
  
  size : (major_axis_length, minor_axis_length)
      lengths with respect to the major and minor axes.
      The minor axis is the shorter axis, while the major axis is
      the longer axis with respect to the orientation
  
      For orientations 'top' and 'bottom', the major axis is
      along the length.
  
      For orientations 'left' and 'right', the major axis is
      along the breadth
  pos : tuple (x, y)
      Position where the colorbar is to be placed with
      respect to the center of the colorbar
  label : str | vispy.visuals.TextVisual
      The label that is to be drawn with the colorbar
      that provides information about the colorbar.
      If a TextVisual object then 'label_color' is ignored.
  label_color : str | vispy.color.Color
      The color of the label and tick labels. This can either be a
      str as the color's name or an actual instace of a vipy.color.Color
  clim : tuple (min, max)
      the minimum and maximum values of the data that
      is given to the colorbar. This is used to draw the scale
      on the side of the colorbar.
  border_width : float (in px)
      The width of the border the colormap should have. This measurement
      is given in pixels
  border_color : str | vispy.color.Color
      The color of the border of the colormap. This can either be a
      str as the color's name or an actual instace of a vipy.color.Color
  
  .. versionchanged:: 0.7
  
      Keyword argument ``label_str`` renamed to `label`.
class_docstr_tok: ["Visual","subclass","displaying","a","colorbar","Parameters","--","--","--","--","--","cmap",":","str","|","vispy.color.ColorMap","Either","the","name","of","the","ColorMap","to","be","used","from","the","standard","set","of","names","(","refer","to","`","vispy.color.get_colormap","`",")",",","or","a","custom","ColorMap","object",".","The","ColorMap","is","used","to","apply","a","gradient","on","the","colorbar",".","orientation",":","{","'left","'",",","'right","'",",","'top","'",",","'bottom","'","}","The","orientation","of","the","colorbar",",","used","for","rendering",".","The","orientation","can","be","thought","of","as","the","position","of","the","label","relative","to","the","color","bar",".","When","the","orientation","is","'left","'","or","'right","'",",","the","colorbar","is","vertically","placed",".","When","it","is","'top","'","or","'bottom","'",",","the","colorbar","is","horizontally","placed",".","*","'top","'",":","the","colorbar","is","horizontal",".","Color","is","applied","from","left","to","right",".","Minimum","corresponds","to","left","and","maximum","to","right",".","Label","is","to","the","top","of","the","colorbar","*","'bottom","'",":","Same","as","top",",","except","that","label","is","to","the","bottom","of","the","colorbar","*","'left","'",":","the","colorbar","is","vertical",".","Color","is","applied","from","bottom","to","top",".","Minimum","corresponds","to","bottom","and","maximum","to","top",".","Label","is","to","the","left","of","the","colorbar","*","'right","'",":","Same","as","left",",","except","that","the","label","is","placed","to","the","right","of","the","colorbar","size",":","(","major_axis_length",",","minor_axis_length",")","lengths","with","respect","to","the","major","and","minor","axes",".","The","minor","axis","is","the","shorter","axis",",","while","the","major","axis","is","the","longer","axis","with","respect","to","the","orientation","For","orientations","'top","'","and","'bottom","'",",","the","major","axis","is","along","the","length",".","For","orientations","'left","'","and","'right","'",",","the","major","axis","is","along","the","breadth","pos",":","tuple","(","x",",","y",")","Position","where","the","colorbar","is","to","be","placed","with","respect","to","the","center","of","the","colorbar","label",":","str","|","vispy.visuals.TextVisual","The","label","that","is","to","be","drawn","with","the","colorbar","that","provides","information","about","the","colorbar",".","If","a","TextVisual","object","then","'label_color","'","is","ignored",".","label_color",":","str","|","vispy.color.Color","The","color","of","the","label","and","tick","labels",".","This","can","either","be","a","str","as","the","color","'s","name","or","an","actual","instace","of","a","vipy.color.Color","clim",":","tuple","(","min",",","max",")","the","minimum","and","maximum","values","of","the","data","that","is","given","to","the","colorbar",".","This","is","used","to","draw","the","scale","on","the","side","of","the","colorbar",".","border_width",":","float","(","in","px",")","The","width","of","the","border","the","colormap","should","have",".","This","measurement","is","given","in","pixels","border_color",":","str","|","vispy.color.Color","The","color","of","the","border","of","the","colormap",".","This","can","either","be","a","str","as","the","color","'s","name","or","an","actual","instace","of","a","vipy.color.Color","..","versionchanged",":",":","0.7","Keyword","argument","``","label_str","``","renamed","to","`","label","`","."]
docstr: Calculate the text centeritions given the ColorBar
  parameters.
  
  Note
  ----
  This is static because in principle, this
  function does not need access to the state of the ColorBar
  at all. It's a computation function that computes coordinate
  transforms
  
  Parameters
  ----------
  center: tuple (x, y)
      Center of the ColorBar
  halfdim: tuple (halfw, halfh)
      Half of the dimensions measured from the center
  border_width: float
      Width of the border of the ColorBar
  orientation: "top" | "bottom" | "left" | "right"
      Position of the label with respect to the ColorBar
  transforms: TransformSystem
      the transforms of the ColorBar
code: def _calc_positions(
      center, halfdim, border_width, orientation, transforms
  ):
      """
      Calculate the text centeritions given the ColorBar
      parameters.
  
      Note
      ----
      This is static because in principle, this
      function does not need access to the state of the ColorBar
      at all. It's a computation function that computes coordinate
      transforms
  
      Parameters
      ----------
      center: tuple (x, y)
          Center of the ColorBar
      halfdim: tuple (halfw, halfh)
          Half of the dimensions measured from the center
      border_width: float
          Width of the border of the ColorBar
      orientation: "top" | "bottom" | "left" | "right"
          Position of the label with respect to the ColorBar
      transforms: TransformSystem
          the transforms of the ColorBar
      """
      (x, y) = center
      (halfw, halfh) = halfdim
  
      visual_to_doc = transforms.get_transform("visual", "document")
      doc_to_visual = transforms.get_transform("document", "visual")
  
      # doc_widths = visual_to_doc.map(np.array([halfw, halfh, 0, 0],
      #                                         dtype=np.float32))
  
      doc_x = visual_to_doc.map(
          np.array([halfw, 0, 0, 0], dtype=np.float32)
      )
      doc_y = visual_to_doc.map(
          np.array([0, halfh, 0, 0], dtype=np.float32)
      )
  
      if doc_x[0] < 0:
          doc_x *= -1
  
      if doc_y[1] < 0:
          doc_y *= -1
  
      # doc_halfw = np.abs(doc_widths[0])
      # doc_halfh = np.abs(doc_widths[1])
  
      if orientation == "top":
          doc_perp_vector = -doc_y
      elif orientation == "bottom":
          doc_perp_vector = doc_y
      elif orientation == "left":
          doc_perp_vector = -doc_x
      if orientation == "right":
          doc_perp_vector = doc_x
  
      perp_len = np.linalg.norm(doc_perp_vector)
      doc_perp_vector /= perp_len
      perp_len += border_width
      perp_len += 5  # pixels
      perp_len *= ColorBarVisual.text_padding_factor
      doc_perp_vector *= perp_len
  
      doc_center = visual_to_doc.map(
          np.array([x, y, 0, 0], dtype=np.float32)
      )
      doc_label_pos = doc_center + doc_perp_vector
      visual_label_pos = doc_to_visual.map(doc_label_pos)[:3]
  
      # next, calculate tick positions
      if orientation in ["top", "bottom"]:
          doc_ticks_pos = [doc_label_pos - doc_x, doc_label_pos + doc_x]
      else:
          doc_ticks_pos = [doc_label_pos + doc_y, doc_label_pos - doc_y]
  
      visual_ticks_pos = []
      visual_ticks_pos.append(doc_to_visual.map(doc_ticks_pos[0])[:3])
      visual_ticks_pos.append(doc_to_visual.map(doc_ticks_pos[1])[:3])
  
      return (visual_label_pos, visual_ticks_pos)
  
imports: from functools import lru_cache
  import numpy
  from .None import Visual, TextVisual, CompoundVisual, _BorderVisual
  from .shaders import Function
  from ..color import get_colormap
label_desc: Use image node_id 6 for calling the ColorBarVisual obj's underlying member method code with example usage: obj._calc_positions(center, halfdim, border_width, orientation, transforms) and returns: visual_label_pos,  visual_ticks_pos