def _make_global_context_block( font_size=3, minimum_distance=10, padding=4, ): assert isinstance(font_size, (int, float)) assert isinstance(padding, (int, float)) block = ContextBlock( type_='Engraver_group', name='GlobalContext', ) block.consists_commands.append('Axis_group_engraver') block.consists_commands.append('Time_signature_engraver') time_signature_grob = override(block).time_signature time_signature_grob.X_extent = (0, 0) time_signature_grob.X_offset = Scheme( 'ly:self-alignment-interface::x-aligned-on-self') time_signature_grob.Y_extent = (0, 0) time_signature_grob.break_align_symbol = False time_signature_grob.break_visibility = Scheme( 'end-of-line-invisible', ) time_signature_grob.font_size = font_size time_signature_grob.self_alignment_X = Scheme('center') spacing_vector = SpacingVector( 0, minimum_distance, padding, 0, ) grob = override(block).vertical_axis_group grob.default_staff_staff_spacing = spacing_vector return block
def __init__(self, symbol=None): if symbol is None: symbol = 'cross' symbol = str(symbol) Scheme.__init__( self, symbol, quoting="'", )
def __init__(self, *args, **kwargs): from abjad.tools import schemetools args_as_pairs = [] for arg in args: if not isinstance(arg, (tuple, schemetools.SchemePair)): message = 'must be Python pair or Scheme pair: "%s".' raise TypeError(message % arg) arg_as_pair = schemetools.SchemePair(*arg) args_as_pairs.append(arg_as_pair) Scheme.__init__(self, *args_as_pairs, **{'quoting': "'"})
def __init__(self, *args, **kwargs): if len(args) == 1 and isinstance(args[0], SchemePair): args = args[0]._value elif len(args) == 1 and isinstance(args[0], tuple): args = args[0][:] elif len(args) == 2: args = args else: message = 'can not initialize Scheme pair from {!r}.' raise TypeError(message.format(args)) Scheme.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): if len(args) == 1 and durationtools.Duration.is_token(args[0]): args = durationtools.Duration(args[0]) elif len(args) == 1 and isinstance(args[0], type(self)): args = args[0].duration elif len(args) == 2 and isinstance(args[0], int) and isinstance(args[1], int): args = durationtools.Duration(args) else: message = 'can not intialize scheme moment from "{}".' raise TypeError(message.format(args)) Scheme.__init__(self, args, **kwargs)
def __init__(self, *args, **kwargs): if len(args) == 1 and isinstance(args[0], SchemePair): args = args[0]._value elif len(args) == 1 and isinstance(args[0], tuple): args = args[0][:] elif len(args) == 2: args = args elif len(args) == 0: args = (0, 1) else: message = 'can not initialize {}: {!r}.' message = message.format(type(self).__name__, args) raise TypeError(message) Scheme.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): if len(args) == 1 and durationtools.Duration.is_token(args[0]): args = durationtools.Duration(args[0]) elif len(args) == 1 and isinstance(args[0], type(self)): args = args[0].duration elif len(args) == 2 and \ isinstance(args[0], int) and isinstance(args[1], int): args = durationtools.Duration(args) elif len(args) == 0: args = durationtools.Duration((1, 4)) else: message = 'can not intialize {}: {!r}.' message = message.format(type(self).__name__, args) raise TypeError(message) Scheme.__init__(self, args, **kwargs)
def __init__(self, value=None): from abjad.tools import schemetools value = value or [] pairs = [] for item in value: if isinstance(item, tuple): pair = schemetools.SchemePair(item) elif isinstance(item, schemetools.SchemePair): pair = item else: message = 'must be Python pair or Scheme pair: {!r}.' message = message.format(item) raise TypeError(message) pairs.append(pair) Scheme.__init__(self, value=pairs, quoting="'")
def __str__(self) -> str: r""" Gets string representation of staff change. .. container:: example Default staff change: >>> staff_change = abjad.StaffChange() >>> print(str(staff_change)) \change Staff = ##f .. container:: example Explicit staff change: >>> lh_staff = abjad.Staff("s2", name='LHStaff') >>> staff_change = abjad.StaffChange(staff=lh_staff) >>> print(str(staff_change)) \change Staff = LHStaff """ if self.staff is None: return r'\change Staff = ##f' value = Scheme.format_scheme_value(self.staff.name) return rf'\change Staff = {value}'
def tweak_string(self): r'''Gets LilyPond grob override \tweak string. >>> override = abjad.LilyPondGrobOverride( ... grob_name='Glissando', ... property_path='style', ... value=abjad.SchemeSymbol('zigzag'), ... ) >>> override.tweak_string "- \\tweak style #'zigzag" Returns string. ''' result = [r'- \tweak'] string = '.'.join(self.property_path) result.append(string) string = Scheme.format_embedded_scheme_value(self.value) result.append(string) return ' '.join(result)
def override_format_pieces(self) -> typing.Tuple[str, ...]: r""" Gets LilyPond grob override \override format pieces. .. container:: example >>> override = abjad.LilyPondGrobOverride( ... lilypond_type='Staff', ... grob_name='TextSpanner', ... once=True, ... property_path=( ... 'bound-details', ... 'left', ... 'text', ... ), ... value=abjad.Markup(r'\bold { over pressure }'), ... ) >>> for line in override.override_format_pieces: ... line ... '\\once \\override Staff.TextSpanner.bound-details.left.text = \\markup {' ' \\bold' ' {' ' over' ' pressure' ' }' ' }' """ result = [] if self.once: result.append(r'\once') result.append(r'\override') result.append(self._override_property_path_string()) result.append('=') value_pieces = Scheme.format_embedded_scheme_value(self.value) value_pieces = value_pieces.split('\n') result.append(value_pieces[0]) result[:] = [' '.join(result)] result.extend(value_pieces[1:]) return tuple(result)
def format_pieces(self) -> typing.Tuple[str, ...]: r""" Gets LilyPond context setting \set or \unset format pieces. """ result = [] if not self.is_unset: result.append(r'\set') else: result.append(r'\unset') if self.lilypond_type is not None: string = f'{self.lilypond_type}.{self.context_property}' result.append(string) else: result.append(self.context_property) result.append('=') value_pieces = Scheme.format_embedded_scheme_value(self.value) value_pieces = value_pieces.split('\n') result.append(value_pieces[0]) result[:] = [' '.join(result)] result.extend(value_pieces[1:]) return tuple(result)
def override_format_pieces(self): r'''Gets LilyPond grob override \override format pieces. >>> override = abjad.LilyPondGrobOverride( ... lilypond_type='Staff', ... grob_name='TextSpanner', ... once=True, ... property_path=( ... 'bound-details', ... 'left', ... 'text', ... ), ... value=abjad.Markup(r'\bold { over pressure }'), ... ) >>> for line in override.override_format_pieces: ... line ... '\\once \\override Staff.TextSpanner.bound-details.left.text = \\markup {' ' \\bold' ' {' ' over' ' pressure' ' }' ' }' Returns tuple of strings. ''' result = [] if self.once: result.append(r'\once') result.append(r'\override') result.append(self._override_property_path_string) result.append('=') value_pieces = Scheme.format_embedded_scheme_value(self.value) value_pieces = value_pieces.split('\n') result.append(value_pieces[0]) result[:] = [' '.join(result)] result.extend(value_pieces[1:]) return tuple(result)
def tweak_string(self, directed=True, grob=False) -> str: r""" Gets LilyPond grob override \tweak string. .. container:: example >>> override = abjad.LilyPondGrobOverride( ... grob_name='Glissando', ... property_path='style', ... value=abjad.SchemeSymbol('zigzag'), ... ) >>> override.tweak_string() "- \\tweak style #'zigzag" .. container:: example >>> override = abjad.LilyPondGrobOverride( ... grob_name='RehearsalMark', ... property_path='color', ... value='red', ... ) >>> override.tweak_string(directed=False) '\\tweak color #red' """ if directed: result = [r'- \tweak'] else: result = [r'\tweak'] if grob: property_path = (self.grob_name,) + self.property_path else: property_path = self.property_path string = '.'.join(property_path) result.append(string) string = Scheme.format_embedded_scheme_value(self.value) result.append(string) return ' '.join(result)
def __init__(self, value=(None, None)): assert isinstance(value, tuple), repr(value) assert len(value) == 2, repr(value) Scheme.__init__(self, value=value)
def __init__(self, *args): Scheme.__init__(self, *args, quoting="'")
def __init__(self, *args): Scheme.__init__(self, *args, **{'quoting': "'"})
def __init__(self, value=[]): Scheme.__init__(self, value, quoting="'#")
def __init__(self, symbol='cross'): symbol = str(symbol) Scheme.__init__(self, value=symbol, quoting="'")