Пример #1
0
 def __init__(
     self, pos_x: Unit, pitch: PitchDef, duration: BeatDef, parent: GraphicObject
 ):
     """
     Args:
         pos_x (Unit): The x-axis position relative to `parent`.
             The y-axis position is calculated automatically based
             on `pitch` and contextual information in `self.staff`.
         pitch (Pitch or str): May be a `str` pitch representation.
             See `Pitch` for valid signatures.
         duration (Beat or init tuple): The logical duration of
             the notehead. This is used to determine the glyph style.
         parent (GraphicObject): Must either be a `Staff` or an object
             with an ancestor `Staff`.
     """
     self._pitch = Pitch.from_def(pitch)
     self._duration = Beat.from_def(duration)
     # Use a temporary y-axis position before calculating it for real
     MusicText.__init__(
         self,
         (pos_x, ZERO),
         [self._glyphnames[self.duration.base_division]],
         parent,
     )
     StaffObject.__init__(self, parent)
     self.y = self.staff.unit(
         self.staff_pos - map_between(self.staff, self.parent).y
     )
Пример #2
0
 def __init__(
     self,
     pos: PointDef,
     parent: Union[StaffObject, Staff],
     duration: BeatDef,
 ):
     pos = Point.from_def(pos)
     self._duration = Beat.from_def(duration)
     MusicText.__init__(self, pos,
                        [self._glyphnames[self.duration.base_division]],
                        parent)
     StaffObject.__init__(self, parent)