예제 #1
0
    def __init__(
        self,
        start: PointDef,
        start_parent: GraphicObject,
        end: PointDef,
        end_parent: Optional[GraphicObject] = None,
    ):
        """
        Args:
            start: The position of the start-pedal mark relative to `start_parent`.
            start_parent: Anchor for the start-pedal mark, which must be in a staff
                or a staff itself.
            end: The position of the release-pedal mark relative to `end_parent`.
            end_parent: An optional anchor for the release-pedal mark. If provided,
                this must be in the same staff as `start_parent`. Otherwise, this
                defaults to `self`.
        """
        ObjectGroup.__init__(self, start, start_parent)
        Spanner2D.__init__(
            self,
            end if isinstance(end, Point) else Point(*end),
            cast(Positioned, end_parent) if end_parent else self,
        )
        StaffObject.__init__(self, self.parent)

        # Add opening pedal mark
        # (GraphicObject init handles registration with ObjectGroup)
        self.depress_mark = MusicText((GraphicUnit(0), GraphicUnit(0)),
                                      "keyboardPedalPed",
                                      parent=self)
        self.lift_mark = MusicText(self.end_pos,
                                   "keyboardPedalUp",
                                   parent=self.end_parent)
예제 #2
0
 def test_init(self):
     mock_parent = InvisibleObject((Unit(10), Unit(11)), parent=self.staff)
     test_object = MusicText((Unit(5), Unit(6)), "accidentalFlat",
                             mock_parent, self.font)
     assert test_object.x == GraphicUnit(5)
     assert test_object.y == GraphicUnit(6)
     assert test_object.text == "\ue260"
     assert test_object.font == self.font
     assert test_object.parent == mock_parent
예제 #3
0
 def setUp(self):
     neoscore.setup()
     self.flowable = Flowable((Mm(0), Mm(0)), Mm(10000), Mm(30), Mm(5))
     self.staff = Staff((Mm(0), Mm(0)), Mm(5000), self.flowable)
     self.left_parent = MockStaffObject((Mm(0), Mm(0)), self.staff)
     self.right_parent = MockStaffObject((Mm(10), Mm(2)), self.staff)
     self.char = "gClef"
     self.single_repetition_width = MusicText((Mm(0), Mm(0)),
                                              self.char,
                                              self.staff,
                                              scale=2).bounding_rect.width
예제 #4
0
 def test_init_with_multiple_chars_in_list(self):
     test_object = MusicText((Unit(5), Unit(6)),
                             ["accidentalFlat", ("brace", 1)], self.staff)
     assert test_object.text == "\ue260\uF400"
예제 #5
0
 def test_init_with_one_music_char(self):
     test_object = MusicText((Unit(5), Unit(6)),
                             MusicChar(self.staff.music_font, "brace", 1),
                             self.staff)
     assert test_object.text == "\uF400"
예제 #6
0
 def test_init_with_one_tuple(self):
     test_object = MusicText((Unit(5), Unit(6)), ("brace", 1), self.staff)
     assert test_object.text == "\uF400"
예제 #7
0
 def __init__(self, pos, parent, length, text, font):
     Event.__init__(self, pos, parent, length)
     self.text = MusicText(pos, text, self, font)
     MusicTextEvent._center_music_text(self.text)