예제 #1
0
 def __init__(
     self,
     start: PointDef,
     start_parent: GraphicObject,
     stop: PointDef,
     stop_parent: GraphicObject,
 ):
     """
     Args:
         start: The starting (left) position of the beam
         start_parent: The parent for the starting position.
             Must be a staff or in one.
         stop: The ending (right) position of the beam
         stop_parent: The parent for the ending position.
             Must be a staff or in one.
     """
     Path.__init__(self, start, parent=start_parent)
     StaffObject.__init__(self, start_parent)
     self.beam_thickness = self.staff.music_font.engraving_defaults[
         "beamThickness"]
     # Draw beam
     stop = Point.from_def(stop)
     self.line_to(stop.x, stop.y, stop_parent)
     self.line_to(stop.x, stop.y + self.beam_thickness, stop_parent)
     self.line_to(ZERO, self.beam_thickness, self)
     self.close_subpath()
예제 #2
0
 def __init__(
     self,
     start: PointDef,
     start_parent: GraphicObject,
     stop: PointDef,
     stop_parent: Optional[GraphicObject],
     direction: int,
     width: Optional[Unit] = None,
 ):
     """
     Args:
         start: The starting point.
         start_parent: The parent for the starting position.
             Must be a staff or in one.
         stop: The stopping point.
         stop_parent: The parent for the ending position.
             If `None`, defaults to `self`.
         direction: The direction of the hairpin, where `-1` means diminuendo (>)
             and `1` means crescendo (<).
         width: The width of the wide hairpin. Defaults to 1 staff unit.
     """
     Path.__init__(self, start, parent=start_parent)
     StaffObject.__init__(self, start_parent)
     stop = Point.from_def(stop)
     Spanner2D.__init__(self, stop, stop_parent or self)
     self.direction = direction
     self.width = width if width is not None else self.staff.unit(1)
     self.thickness = self.staff.music_font.engraving_defaults[
         "hairpinThickness"]
     self._draw_path()
예제 #3
0
 def __init__(
     self,
     start: PointDef,
     start_parent: GraphicObject,
     stop: PointDef,
     stop_parent: Optional[GraphicObject],
     direction: int = -1,
 ):
     """
     Args:
         start: The starting point.
         start_parent: The parent for the starting position.
             Must be a staff or in one.
         stop: The stopping point.
         stop_parent: The parent for the ending position.
             If `None`, defaults to `self`.
         direction: The direction of the slur, where
             `-1` indicates curving upward, and `1` vice versa.
     """
     Path.__init__(self,
                   start,
                   parent=start_parent,
                   brush=Brush((0, 0, 0, 255)))
     StaffObject.__init__(self, self.parent)
     stop = Point.from_def(stop)
     Spanner2D.__init__(self, stop, stop_parent or self)
     self.direction = direction
     # Load relevant engraving defaults from music font
     engraving_defaults = self.staff.music_font.engraving_defaults
     self.midpoint_thickness = self.staff.unit(
         engraving_defaults["slurMidpointThickness"])
     self.endpoint_thickness = self.staff.unit(
         engraving_defaults["slurEndpointThickness"])
     self._draw_path()
예제 #4
0
파일: rest.py 프로젝트: ajyoon/brown
 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)
예제 #5
0
 def pos(self, value: PointDef):
     self._pos = Point.from_def(value)