markups

Tools for modeling LilyPond’s markup and postscript.

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.markups" { graph [label="abjad.markups"]; node [color=1]; "abjad.markups.Markup" [URL="../api/abjad/markups.html#abjad.markups.Markup", color=black, fontcolor=white, label=Markup, target=_top]; "abjad.markups.MarkupCommand" [URL="../api/abjad/markups.html#abjad.markups.MarkupCommand", color=black, fontcolor=white, label="Markup\nCommand", target=_top]; "abjad.markups.MarkupList" [URL="../api/abjad/markups.html#abjad.markups.MarkupList", color=black, fontcolor=white, label="Markup\nList", target=_top]; "abjad.markups.Postscript" [URL="../api/abjad/markups.html#abjad.markups.Postscript", color=black, fontcolor=white, label=Postscript, target=_top]; "abjad.markups.PostscriptOperator" [URL="../api/abjad/markups.html#abjad.markups.PostscriptOperator", color=black, fontcolor=white, label="Postscript\nOperator", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph "cluster_abjad.utilities" { graph [label="abjad.utilities"]; node [color=3]; "abjad.utilities.TypedCollection.TypedCollection" [URL="../api/abjad/utilities/TypedCollection.html#abjad.utilities.TypedCollection.TypedCollection", label="Typed\nCollection", shape=oval, style=bold, target=_top]; "abjad.utilities.TypedList.TypedList" [URL="../api/abjad/utilities/TypedList.html#abjad.utilities.TypedList.TypedList", label="Typed\nList", target=_top]; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.TypedList.TypedList"; } subgraph cluster_builtins { graph [label=builtins]; node [color=4]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=5]; "collections.abc.Collection" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.MutableSequence" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.MutableSequence", label="Mutable\nSequence", shape=oval, style=bold, target=_top]; "collections.abc.Reversible" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Reversible", label=Reversible, shape=oval, style=bold, target=_top]; "collections.abc.Sequence" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sequence", label=Sequence, shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sized", label=Sized, shape=oval, style=bold, target=_top]; "collections.abc.Collection" -> "collections.abc.Sequence"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Reversible"; "collections.abc.Reversible" -> "collections.abc.Sequence"; "collections.abc.Sequence" -> "collections.abc.MutableSequence"; "collections.abc.Sized" -> "collections.abc.Collection"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.TypedCollection.TypedCollection"; "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.markups.Markup"; "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.markups.MarkupCommand"; "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.markups.Postscript"; "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.markups.PostscriptOperator"; "abjad.utilities.TypedList.TypedList" -> "abjad.markups.MarkupList"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.MutableSequence" -> "abjad.utilities.TypedList.TypedList"; }


Classes

Markup LilyPond markup.
MarkupCommand LilyPond markup command.
MarkupList Markup list.
Postscript Postscript session.
PostscriptOperator Postscript operator.
class abjad.markups.Markup(contents=None, *, direction=None, literal=None, tweaks=None)

LilyPond markup.

Initializes from string:

>>> string = r'\italic { "Allegro assai" }'
>>> markup = abjad.Markup(string)
>>> abjad.f(markup)
\markup {
    \italic
        {
            "Allegro assai"
        }
    }
>>> abjad.show(markup) 

Initializes from other markup:

>>> markup = abjad.Markup('Allegro assai', direction=abjad.Up)
>>> markup = markup.italic()
>>> markup = abjad.Markup(markup, direction=abjad.Down)
>>> abjad.f(markup)
_ \markup {
    \italic
        "Allegro assai"
    }
>>> abjad.show(markup) 

Attaches markup to score components:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> string = r'\italic { "Allegro assai" }'
>>> markup = abjad.Markup(string, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \italic
        {
            "Allegro assai"
        }
    }
>>> abjad.attach(markup, staff[0])
>>> abjad.show(staff) 

Note

Make sure all static markup methods implement a direction keyword when extending this class.

Set direction to Up, Down, 'neutral', '^', '_', '-' or None.

Markup can be tagged:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> markup = abjad.Markup('Allegro', direction=abjad.Up).italic()
>>> abjad.attach(markup, staff[0], tag='RED:M1')
>>> abjad.show(staff) 
>>> abjad.f(staff)
\new Staff
{
    c'4
    ^ \markup {     %! RED:M1
        \italic     %! RED:M1
            Allegro %! RED:M1
        }           %! RED:M1
    d'4
    e'4
    f'4
}

Markup can be deactively tagged:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> markup = abjad.Markup('Allegro', direction=abjad.Up).italic()
>>> abjad.attach(
...     markup,
...     staff[0],
...     deactivate=True,
...     tag='RED:M1',
...     )
>>> abjad.show(staff) 
>>> abjad.f(staff)
\new Staff
{
    c'4
%@% ^ \markup {         %! RED:M1
%@%     \italic         %! RED:M1
%@%         Allegro     %! RED:M1
%@%     }               %! RED:M1
    d'4
    e'4
    f'4
}

REGRESSION: make sure the first italic markup doesn’t disappear after the second italic markup is attached:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> markup_1 = abjad.Markup('Allegro', direction=abjad.Up).italic()
>>> markup_2 = abjad.Markup('non troppo', direction=abjad.Up).italic()
>>> abjad.attach(markup_1, staff[0])
>>> abjad.attach(markup_2, staff[0])
>>> abjad.show(staff) 
>>> abjad.f(staff)
\new Staff
{
    c'4
    ^ \markup {
        \italic
            Allegro
        }
    ^ \markup {
        \italic
            "non troppo"
        }
    d'4
    e'4
    f'4
}

Attributes Summary

__add__ Adds markup to argument.
__copy__ Copies markup.
__eq__ Is true markup equals argument.
__format__ Formats markup.
__hash__ Hashes markup.
__illustrate__ Illustrates markup.
__lt__ Is true when markup contents compare less than argument contents.
__radd__ Adds argument to markup.
__str__ Gets string representation of markup.
abjad_metronome_mark Abjad \abjad-metronome-mark-markup command.
bold LilyPond \bold markup command.
box LilyPond \box markup command.
bracket LilyPond \bracket markup command.
caps LilyPond \caps markup command.
center_align LilyPond \center-align markup command.
center_column LilyPond \center-column markup command.
circle LilyPond \circle markup command.
column LilyPond \column markup command.
combine LilyPond \combine markup command.
concat LilyPond \concat markup command.
contents Gets contents of markup.
direction Gets direction of markup.
draw_circle LilyPond \draw-circle markup command.
draw_line LilyPond \draw-line markup command.
dynamic LilyPond \dynamic markup command.
filled_box LilyPond filled-box markup command.
finger LilyPond \finger markup command.
flat LilyPond \flat markup command.
fontsize LilyPond \fontsize markup command.
fraction LilyPond \fraction markup command.
from_literal Makes markup from literal string and bypasses parser.
general_align LilyPond \general-align markup command.
halign LilyPond halign markup command.
hcenter_in LilyPond \hcenter-in markup command.
hspace LilyPond \hspace markup command.
huge LilyPond \huge markup command.
italic LilyPond \italic markup command.
larger LilyPond \larger markup command.
left_column LilyPond \left-column markup command.
line LilyPond \line markup command.
literal Is true when markup formats contents literally.
make_improper_fraction_markup Makes improper fraction markup.
musicglyph LilyPond \musicglyph markup command.
natural LilyPond \natural markup command.
normal_text LilyPond \bold markup command.
note_by_number LilyPond \note-by-number markup command.
null LilyPond \null markup command.
overlay LilyPond \overlay markup command.
override LilyPond \override markup command.
pad_around LilyPond \pad-around markup command.
pad_markup LilyPond \pad-markup markup command.
pad_to_box LilyPond pad-to-box markup command.
parenthesize LilyPond \parenthesize markup command.
postscript LilyPond \postscript markup command.
raise_ LilyPond \raise markup command.
right_column LilyPond \right-column markup command.
rotate LilyPond \rotate markup command.
sans LilyPond \sans markup command.
scale LilyPond \scale markup command.
sharp LilyPond \sharp markup command.
small LilyPond \small markup command.
smaller LilyPond \smaller markup command.
sub LilyPond \sub markup command.
super LilyPond \super markup command.
tiny LilyPond \tiny markup command.
translate LilyPond translate markup command.
triangle LilyPond \triangle markup command.
tweaks Gets tweaks.
upright LilyPond \upright markup command.
vcenter LilyPond \vcenter markup command.
vspace LilyPond \vspace markup command.
whiteout LilyPond \whiteout markup command.
with_color LilyPond \with-color markup command.
with_dimensions LilyPond with-dimensions markup command.
with_dimensions_from LilyPond with-dimensions markup command.
with_literal Makes markup with literal string.

Special methods

__add__(argument)

Adds markup to argument.

Adds markup to markup:

>>> markup = abjad.Markup('Allegro') + abjad.Markup('assai')
>>> abjad.f(markup)
\markup {
    Allegro
    assai
    }
>>> abjad.show(markup) 

Adds markup command to markup:

>>> markup = abjad.Markup('Allegro') + abjad.Markup.hspace(0.75)
>>> markup = markup + abjad.Markup('assai')
>>> abjad.f(markup)
\markup {
    Allegro
    \hspace
        #0.75
    assai
    }
>>> abjad.show(markup) 

Returns new markup.

__copy__(*arguments)

Copies markup.

>>> import copy
>>> markup_1 = abjad.Markup('Allegro assai', direction=abjad.Up)
>>> markup_2 = copy.copy(markup_1)
>>> markup_1
Markup(contents=['Allegro assai'], direction=Up)
>>> markup_2
Markup(contents=['Allegro assai'], direction=Up)
>>> markup_1 == markup_2
True
>>> markup_1 is markup_2
False

Returns new markup.

__eq__(argument)

Is true markup equals argument.

Without keywords:

>>> markup_1 = abjad.Markup('Allegro')
>>> markup_2 = abjad.Markup('Allegro')
>>> markup_3 = abjad.Markup('Allegro assai')
>>> markup_1 == markup_1
True
>>> markup_1 == markup_2
True
>>> markup_1 == markup_3
False
>>> markup_2 == markup_1
True
>>> markup_2 == markup_2
True
>>> markup_2 == markup_3
False
>>> markup_3 == markup_1
False
>>> markup_3 == markup_2
False
>>> markup_3 == markup_3
True

With keywords:

>>> markup_1 = abjad.Markup('Allegro')
>>> markup_2 = abjad.Markup('Allegro', direction=abjad.Up)
>>> markup_1 == markup_1
True
>>> markup_1 == markup_2
False
>>> markup_2 == markup_1
False
>>> markup_2 == markup_2
True

Returns new markup.

__format__(format_specification='')

Formats markup.

Formats markup:

>>> string = r'\italic { Allegro assai }'
>>> markup = abjad.Markup(string)
>>> abjad.f(markup)
\markup {
    \italic
        {
            Allegro
            assai
        }
    }

Returns string.

__hash__()

Hashes markup.

Without keywords:

>>> hash_1 = hash(abjad.Markup('Allegro'))
>>> hash_2 = hash(abjad.Markup('Allegro'))
>>> hash_3 = hash(abjad.Markup('Allegro assai'))
>>> hash_1 == hash_1
True
>>> hash_1 == hash_2
True
>>> hash_1 == hash_3
False
>>> hash_2 == hash_1
True
>>> hash_2 == hash_2
True
>>> hash_2 == hash_3
False
>>> hash_3 == hash_1
False
>>> hash_3 == hash_2
False
>>> hash_3 == hash_3
True

With keywords:

>>> hash_1 = hash(abjad.Markup('Allegro'))
>>> hash_2 = hash(abjad.Markup('Allegro', direction=abjad.Up))
>>> hash_1 == hash_1
True
>>> hash_1 == hash_2
False
>>> hash_2 == hash_1
False
>>> hash_2 == hash_2
True
__illustrate__()

Illustrates markup.

>>> string = r'\italic { Allegro assai }'
>>> markup = abjad.Markup(string)
>>> abjad.f(markup)
\markup {
    \italic
        {
            Allegro
            assai
        }
    }
>>> abjad.show(markup) 

Returns LilyPond file.

__lt__(argument)

Is true when markup contents compare less than argument contents.

>>> markup_1 = abjad.Markup('Allegro')
>>> markup_2 = abjad.Markup('assai')
>>> markup_1 < markup_2
True
>>> markup_2 < markup_1
False

Raises type error when argument is not markup.

Returns true or false.

__radd__(argument)

Adds argument to markup.

Adds markup to markup:

>>> markup = abjad.Markup('Allegro') + abjad.Markup('assai')
>>> abjad.f(markup)
\markup {
    Allegro
    assai
    }
>>> abjad.show(markup) 

Adds markup to markup command:

>>> markup = abjad.Markup('Allegro') + abjad.Markup.hspace(0.75)
>>> markup = markup + abjad.Markup('assai')
>>> abjad.f(markup)
\markup {
    Allegro
    \hspace
        #0.75
    assai
    }
>>> abjad.show(markup) 

Returns new markup.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of markup.

>>> string = r'\italic { Allegro assai }'
>>> markup = abjad.Markup(string)
>>> print(str(markup))
\markup {
    \italic
        {
            Allegro
            assai
        }
    }
>>> abjad.show(markup) 

Returns string.


Methods

bold()

LilyPond \bold markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.bold()
>>> abjad.f(markup)
\markup {
    \bold
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

box()

LilyPond \box markup command.

Default box:

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.box()
>>> abjad.f(markup)
\markup {
    \box
        "Allegro assai"
    }
>>> abjad.show(markup) 

Customized box:

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.box()
>>> markup = markup.override(('box-padding', 0.5))
>>> abjad.f(markup)
\markup {
    \override
        #'(box-padding . 0.5)
        \box
            "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

bracket()

LilyPond \bracket markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.bracket()
>>> abjad.f(markup)
\markup {
    \bracket
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

caps()

LilyPond \caps markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.caps()
>>> abjad.f(markup)
\markup {
    \caps
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

center_align()

LilyPond \center-align markup command.

>>> markup_a = abjad.Markup('allegro')
>>> markup_b = abjad.Markup('non').center_align()
>>> markup_c = abjad.Markup('troppo')
>>> markup = abjad.Markup.column([markup_a, markup_b, markup_c])
>>> abjad.f(markup)
\markup {
    \column
        {
            allegro
            \center-align
                non
            troppo
        }
    }
>>> abjad.show(markup) 

Returns new markup

circle()

LilyPond \circle markup command.

>>> markup = abjad.Markup.fraction(3, 5)
>>> markup = markup.circle()
>>> markup = markup.override(('circle-padding', 0.45))
>>> abjad.f(markup)
\markup {
    \override
        #'(circle-padding . 0.45)
        \circle
            \fraction
                3
                5
    }
>>> abjad.show(markup) 

Returns new markup

dynamic()

LilyPond \dynamic markup command.

>>> markup = abjad.Markup('sffz')
>>> markup = markup.dynamic()
>>> abjad.f(markup)
\markup {
    \dynamic
        sffz
    }
>>> abjad.show(markup) 

Returns new markup.

finger()

LilyPond \finger markup command.

>>> markup = abjad.Markup(1)
>>> markup = markup.finger()
>>> abjad.f(markup)
\markup {
    \finger
        1
    }
>>> abjad.show(markup) 

Returns new markup

fontsize(fontsize)

LilyPond \fontsize markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.fontsize(-3)
>>> abjad.f(markup)
\markup {
    \fontsize
        #-3
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup

general_align(axis, direction)

LilyPond \general-align markup command.

With Abjad direction constant:

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.general_align('Y', direction=abjad.Up)
>>> abjad.f(markup)
\markup {
    \general-align
        #Y
        #UP
        "Allegro assai"
    }
>>> abjad.show(markup) 

With numeric direction value:

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.general_align('Y', 0.75)
>>> abjad.f(markup)
\markup {
    \general-align
        #Y
        #0.75
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

halign(direction)

LilyPond halign markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.halign(0)
>>> abjad.f(markup)
\markup {
    \halign
        #0
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

hcenter_in(length)

LilyPond \hcenter-in markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.hcenter_in(12)
>>> abjad.f(markup)
\markup {
    \hcenter-in
        #12
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

huge()

LilyPond \huge markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.huge()
>>> abjad.f(markup)
\markup {
    \huge
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

italic()

LilyPond \italic markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.italic()
>>> abjad.f(markup)
\markup {
    \italic
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

larger()

LilyPond \larger markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.larger()
>>> abjad.f(markup)
\markup {
    \larger
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

normal_text()

LilyPond \bold markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.normal_text()
>>> abjad.f(markup)
\markup {
    \normal-text
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

override(pair)

LilyPond \override markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.parenthesize()
>>> markup = markup.override(('padding', 0.75))
>>> abjad.f(markup)
\markup {
    \override
        #'(padding . 0.75)
        \parenthesize
            "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

pad_around(padding)

LilyPond \pad-around markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.pad_around(10)
>>> markup = markup.box()
>>> abjad.f(markup)
\markup {
    \box
        \pad-around
            #10
            "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

pad_markup(padding)

LilyPond \pad-markup markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.pad_markup(10)
>>> markup = markup.box()
>>> abjad.f(markup)
\markup {
    \box
        \pad-markup
            #10
            "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

pad_to_box(x_extent, y_extent)

LilyPond pad-to-box markup command.

Positive extents.

The following postscript describes a filled box between the x-coordinates of 0 and 10 and the y-coordinates of 0 and 10. Normally, this would be drawn off the edge of the page.

>>> up_postscript = abjad.Postscript()
>>> up_postscript = up_postscript.newpath()
>>> up_postscript = up_postscript.moveto(0, 0)
>>> up_postscript = up_postscript.rlineto(10, 0)
>>> up_postscript = up_postscript.rlineto(0, 10)
>>> up_postscript = up_postscript.rlineto(-10, 0)
>>> up_postscript = up_postscript.closepath()
>>> up_postscript = up_postscript.setgray(0.75)
>>> up_postscript = up_postscript.fill()
>>> up_postscript_markup = up_postscript.as_markup()
>>> abjad.f(up_postscript_markup)
\markup {
    \postscript
        #"
        newpath
        0 0 moveto
        10 0 rlineto
        0 10 rlineto
        -10 0 rlineto
        closepath
        0.75 setgray
        fill
        "
    }

Notice how the top half of the square is cut off. The coordinates of the postscript put most of the drawing off the edge of the page. LilyPond does not know what the size of the postscript is, so it does not attempt to reposition it:

>>> abjad.show(up_postscript_markup) 

Wrapping the postscript in a box shows that LilyPond believes the postscript has effectively no x or y extent:

>>> abjad.show(up_postscript_markup.box()) 

By giving the postscript markup explicit extents, we can instruct LilyPond to position it properly:

>>> up_postscript_markup = up_postscript_markup.pad_to_box(
...     (0, 10), (0, 10))
>>> abjad.show(up_postscript_markup) 

Boxing also shows that extents have been applied correctly:

>>> abjad.show(up_postscript_markup.box()) 

Negative extents.

LilyPond does not appear to handle negative extents in the same was as it handles positive extents.

The following postscript describes a box of the same shape as in the previous example. However, this box’s x- and y-coordinates range between 0 and 10 and 0 and -10 respectively.

>>> down_postscript = abjad.Postscript()
>>> down_postscript = down_postscript.newpath()
>>> down_postscript = down_postscript.moveto(0, 0)
>>> down_postscript = down_postscript.rlineto(10, 0)
>>> down_postscript = down_postscript.rlineto(0, -10)
>>> down_postscript = down_postscript.rlineto(-10, 0)
>>> down_postscript = down_postscript.closepath()
>>> down_postscript = down_postscript.setgray(0.75)
>>> down_postscript = down_postscript.fill()
>>> down_postscript_markup = down_postscript.as_markup()
>>> abjad.f(down_postscript_markup)
\markup {
    \postscript
        #"
        newpath
        0 0 moveto
        10 0 rlineto
        0 -10 rlineto
        -10 0 rlineto
        closepath
        0.75 setgray
        fill
        "
    }

This time, the entire markup appears to display, without being cut off:

>>> abjad.show(down_postscript_markup) 

However, boxing the markup shows that LilyPond still believes it to be of 0-height and 0-width. Notice that the box appears in a different corner of the grey square than in the previous example. This corner is the markup origin. The grey box in example 2 descends from the origin, while the grey box in example 1 ascends from it.

>>> abjad.show(down_postscript_markup.box()) 

Giving the postscript markup positive extents does not work:

>>> markup = down_postscript_markup.pad_to_box(
...     (0, 10), (0, 10))
>>> abjad.show(markup.box()) 

Likewise, giving the postscript markup negative extents also does not work. The negative extents are treated as 0. In this case, the postscript markup is treated as though it had a height of 0:

>>> markup = down_postscript_markup.pad_to_box(
...     (0, 10), (0, -10))
>>> abjad.show(markup.box()) 

Unfortunately, this means that any part of a postscript-created markup that uses negative coordinates cannot be treated properly by LilyPond’s markup spacing logic. To avoid this, only use positive coordinates in postscript.

Returns new markup.

parenthesize()

LilyPond \parenthesize markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.parenthesize()
>>> abjad.f(markup)
\markup {
    \parenthesize
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

raise_(amount)

LilyPond \raise markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.raise_(0.35)
>>> abjad.f(markup)
\markup {
    \raise
        #0.35
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

rotate(angle)

LilyPond \rotate markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.rotate(45)
>>> abjad.f(markup)
\markup {
    \rotate
        #45
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

sans()

LilyPond \sans markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.sans()
>>> abjad.f(markup)
\markup {
    \sans
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

scale(factor_pair)

LilyPond \scale markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.scale((0.75, 0.75))
>>> abjad.f(markup)
\markup {
    \scale
        #'(0.75 . 0.75)
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

small()

LilyPond \small markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.small()
>>> abjad.f(markup)
\markup {
    \small
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

smaller()

LilyPond \smaller markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.smaller()
>>> abjad.f(markup)
\markup {
    \smaller
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

sub()

LilyPond \sub markup command.

>>> markup_list = [
...     abjad.Markup('A'),
...     abjad.Markup('j').sub(),
...     ]
>>> markup = abjad.Markup.concat(markup_list)
>>> abjad.f(markup)
\markup {
    \concat
        {
            A
            \sub
                j
        }
    }
>>> abjad.show(markup) 

Returns new markup.

super()

LilyPond \super markup command.

>>> markups = [
...     abjad.Markup('1'),
...     abjad.Markup('st').super(),
...     ]
>>> markup_list = abjad.MarkupList(markups)
>>> markup = markup_list.concat()
>>> abjad.f(markup)
\markup {
    \concat
        {
            1
            \super
                st
        }
    }
>>> abjad.show(markup) 

Returns new markup.

tiny()

LilyPond \tiny markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.tiny()
>>> abjad.f(markup)
\markup {
    \tiny
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

translate(offset_pair)

LilyPond translate markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.translate((2, 1))
>>> abjad.f(markup)
\markup {
    \translate
        #'(2 . 1)
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

upright()

LilyPond \upright markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.upright()
>>> abjad.f(markup)
\markup {
    \upright
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

vcenter()

LilyPond \vcenter markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.vcenter()
>>> abjad.f(markup)
\markup {
    \vcenter
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

whiteout()

LilyPond \whiteout markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.whiteout()
>>> abjad.f(markup)
\markup {
    \whiteout
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

with_color(color)

LilyPond \with-color markup command.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.with_color('blue')
>>> abjad.f(markup)
\markup {
    \with-color
        #blue
        "Allegro assai"
    }
>>> abjad.show(markup) 

X-11 colors are supported:

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.with_color(abjad.SchemeColor('LimeGreen'))
>>> abjad.f(markup)
\markup {
    \with-color
        #(x11-color 'LimeGreen)
        "Allegro assai"
    }
>>> abjad.show(markup) 

Returns new markup.

with_dimensions(x_extent, y_extent)

LilyPond with-dimensions markup command.

Note

See the API entry for Markup.pad_to_box() for an extensive discussion of setting explicit markup extents.

>>> up_postscript = abjad.Postscript()
>>> up_postscript = up_postscript.newpath()
>>> up_postscript = up_postscript.moveto(0, 0)
>>> up_postscript = up_postscript.rlineto(10, 0)
>>> up_postscript = up_postscript.rlineto(0, 10)
>>> up_postscript = up_postscript.rlineto(-10, 0)
>>> up_postscript = up_postscript.closepath()
>>> up_postscript = up_postscript.setgray(0.75)
>>> up_postscript = up_postscript.fill()
>>> up_markup = up_postscript.as_markup()
>>> abjad.show(up_markup.box()) 
>>> up_markup = up_markup.with_dimensions((0, 10), (0, 10))
>>> up_markup = up_markup.box()
>>> abjad.show(up_markup) 
>>> up_markup = up_postscript.as_markup()
>>> up_markup = up_markup.with_dimensions((0, 20), (0, 20))
>>> up_markup = up_markup.box()
>>> abjad.show(up_markup) 
>>> up_markup = up_postscript.as_markup()
>>> up_markup = up_markup.with_dimensions((0, 20), (0, -20))
>>> up_markup = up_markup.box()
>>> abjad.show(up_markup) 
>>> down_postscript = abjad.Postscript()
>>> down_postscript = down_postscript.newpath()
>>> down_postscript = down_postscript.moveto(0, 0)
>>> down_postscript = down_postscript.rlineto(10, 0)
>>> down_postscript = down_postscript.rlineto(0, -10)
>>> down_postscript = down_postscript.rlineto(-10, 0)
>>> down_postscript = down_postscript.closepath()
>>> down_postscript = down_postscript.setgray(0.75)
>>> down_postscript = down_postscript.fill()
>>> down_markup = down_postscript.as_markup()
>>> abjad.show(down_markup.box()) 
>>> down_markup = down_markup.with_dimensions((0, 10), (0, 10))
>>> down_markup = down_markup.box()
>>> abjad.show(down_markup) 
>>> down_markup = down_postscript.as_markup()
>>> down_markup = down_markup.with_dimensions(
...     (0, 10), (0, -10))
>>> down_markup = down_markup.box()
>>> abjad.show(down_markup) 
>>> down_markup = down_postscript.as_markup()
>>> down_markup = down_markup.with_dimensions(
...     (-5, 15), (5, -15))
>>> down_markup = down_markup.box()
>>> abjad.show(down_markup) 

Simple example:

>>> markup = abjad.Markup('Allegro').box()
>>> abjad.show(markup) 
>>> markup = abjad.Markup('Allegro')
>>> markup = markup.with_dimensions((-10, 10), (-10, 10))
>>> markup = markup.box()
>>> abjad.show(markup) 

Returns new markup.

with_dimensions_from(command)

LilyPond with-dimensions markup command.

>>> staff = abjad.Staff("c'8 d' e' f'")
>>> markup = abjad.Markup('Allegro', direction=abjad.Up)
>>> markup = markup.with_dimensions_from(r'\null')
>>> abjad.attach(markup, staff[0])
>>> markup = abjad.Markup('non troppo', direction=abjad.Up)
>>> markup = markup.with_dimensions_from(r'\null')
>>> abjad.attach(markup, staff[1])
>>> abjad.show(staff) 
with_literal(string)

Makes markup with literal string.

>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.bold()
>>> markup = markup.with_literal(r'\user-markup-command')
>>> abjad.f(markup)
\markup {
    \user-markup-command
        \bold
            "Allegro assai"
    }
>>> markup = abjad.Markup('Allegro assai')
>>> markup = markup.with_literal(r'\user-markup-command')
>>> markup = markup.bold()
>>> abjad.f(markup)
\markup {
    \bold
        \user-markup-command
            "Allegro assai"
    }

Returns new markup.


Class & static methods

classmethod abjad_metronome_mark(duration_log, dot_count, stem_height, units_per_minute, direction=None)

Abjad \abjad-metronome-mark-markup command.

>>> markup = abjad.Markup.abjad_metronome_mark(
...     2, 0, 1, 67.5, direction=abjad.Up,
...     )
>>> abjad.f(markup)
^ \markup {
    \abjad-metronome-mark-markup #2 #0 #1 #"67.5"
    }
>>> abjad.show(markup) 

Returns new markup

classmethod center_column(markup_list, direction=None)

LilyPond \center-column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup = abjad.Markup.center_column([city, date])
>>> abjad.f(markup)
\markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Also works with a list of strings:

>>> city = 'Los Angeles'
>>> date = 'May - August 2014'
>>> markup = abjad.Markup.center_column([city, date])
>>> abjad.f(markup)
\markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod column(markup_list, direction=None)

LilyPond \column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup = abjad.Markup.column([city, date])
>>> abjad.f(markup)
\markup {
    \column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod combine(markup_list, direction=None)

LilyPond \combine markup command.

>>> markup_one = abjad.Markup('Allegro assai')
>>> markup_two = abjad.Markup.draw_line(13, 0)
>>> markup_list = [markup_one, markup_two]
>>> markup = abjad.Markup.combine(markup_list, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \combine
        "Allegro assai"
        \draw-line
            #'(13 . 0)
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod concat(markup_list, direction=None)

LilyPond \concat markup command.

>>> downbow = abjad.Markup.musicglyph('scripts.downbow')
>>> hspace = abjad.Markup.hspace(1)
>>> upbow = abjad.Markup.musicglyph('scripts.upbow')
>>> markup_list = [downbow, hspace, upbow]
>>> markup = abjad.Markup.concat(markup_list, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \concat
        {
            \musicglyph
                #"scripts.downbow"
            \hspace
                #1
            \musicglyph
                #"scripts.upbow"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod draw_circle(radius, thickness, direction=None, filled=False)

LilyPond \draw-circle markup command.

>>> markup = abjad.Markup.draw_circle(10, 1.5, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \draw-circle
        #10
        #1.5
        ##f
    }
>>> abjad.show(markup) 

Returns new markup

classmethod draw_line(x, y, direction=None)

LilyPond \draw-line markup command.

>>> markup = abjad.Markup.draw_line(5, -2.5, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \draw-line
        #'(5 . -2.5)
    }
>>> abjad.show(markup) 

Returns new markup

classmethod filled_box(x_extent, y_extent, blot=0, direction=None)

LilyPond filled-box markup command.

>>> markup = abjad.Markup.filled_box((0, 10), (2, 5), 1.5, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \filled-box
        #'(0 . 10)
        #'(2 . 5)
        #1.5
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod flat(direction=None)

LilyPond \flat markup command.

>>> markup = abjad.Markup.flat(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \flat
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod fraction(numerator, denominator, direction=None)

LilyPond \fraction markup command.

Fraction with integer numerator and denominator:

>>> markup = abjad.Markup.fraction(1, 4, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \fraction
        1
        4
    }
>>> abjad.show(markup) 

Fraction with string numerator and integer denominator:

>>> markup = abjad.Markup.fraction('π', 4)
>>> abjad.f(markup)
\markup {
    \fraction
        π
        4
    }
>>> abjad.show(markup) 

Returns new markup

classmethod from_literal(string, direction=None, literal=None)

Makes markup from literal string and bypasses parser.

>>> markup = abjad.Markup.from_literal('F#4')
>>> abjad.f(markup)
\markup { "F#4" }
>>> abjad.show(markup) 

Returns new markup.

classmethod hspace(amount, direction=None)

LilyPond \hspace markup command.

>>> markup = abjad.Markup.hspace(0.75, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \hspace
        #0.75
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod left_column(markup_list, direction=None)

LilyPond \left-column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup = abjad.Markup.left_column([city, date])
>>> abjad.f(markup)
\markup {
    \left-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod line(markup_list, direction=None, deactivate=None, tag=None)

LilyPond \line markup command.

>>> markups = ['Allegro', 'assai']
>>> markups = [abjad.Markup(_) for _ in markups]
>>> markup = abjad.Markup.line(markups)
>>> abjad.f(markup)
\markup {
    \line
        {
            Allegro
            assai
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod make_improper_fraction_markup(rational, direction=None)

Makes improper fraction markup.

With integer-equivalent number:

>>> markup = abjad.Markup.make_improper_fraction_markup(
...     abjad.Fraction(6, 3),
...     direction=abjad.Up,
...     )
>>> abjad.f(markup)
^ \markup { 2 }
>>> abjad.show(markup) 

With non-integer-equivalent number:

>>> markup = abjad.Markup.make_improper_fraction_markup(
...     abjad.Fraction(7, 3),
...     )
>>> abjad.f(markup)
\markup {
    2
    \tiny
        \fraction
            1
            3
    }
>>> abjad.show(markup) 
classmethod musicglyph(glyph_name=None, direction=None)

LilyPond \musicglyph markup command.

>>> markup = abjad.Markup.musicglyph(
...     'accidentals.sharp',
...     direction=abjad.Up,
...     )
>>> abjad.f(markup)
^ \markup {
    \musicglyph
        #"accidentals.sharp"
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod natural(direction=None)

LilyPond \natural markup command.

>>> markup = abjad.Markup.natural(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \natural
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod note_by_number(log, dot_count, stem_direction, direction=None)

LilyPond \note-by-number markup command.

>>> markup = abjad.Markup.note_by_number(3, 2, 1, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \note-by-number
        #3
        #2
        #1
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod null(direction=None)

LilyPond \null markup command.

>>> markup = abjad.Markup.null()
>>> abjad.f(markup)
\markup {
    \null
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod overlay(markup_list, direction=None)

LilyPond \overlay markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup = abjad.Markup.overlay([city, date], direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \overlay
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod postscript(postscript, direction=None)

LilyPond \postscript markup command.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.moveto(1, 1)
>>> postscript = postscript.setlinewidth(2.5)
>>> postscript = postscript.setdash((2, 1))
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> markup = abjad.Markup.postscript(postscript, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \postscript
        #"
        1 1 moveto
        2.5 setlinewidth
        [ 2 1 ] 0 setdash
        3 -4 lineto
        stroke
        "
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod right_column(markup_list, direction=None)

LilyPond \right-column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup = abjad.Markup.right_column(
...     [city, date],
...     direction=abjad.Up,
...     )
>>> abjad.f(markup)
^ \markup {
    \right-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod sharp(direction=None)

LilyPond \sharp markup command.

>>> markup = abjad.Markup.sharp(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \sharp
    }
>>> abjad.show(markup) 

Returns new markup.

classmethod triangle(direction=None, is_filled=True)

LilyPond \triangle markup command.

>>> markup = abjad.Markup.triangle(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \triangle
        ##t
    }
>>> abjad.show(markup) 

Returns new markup

classmethod vspace(amount, direction=None)

LilyPond \vspace markup command.

>>> markup = abjad.Markup.vspace(0.75, direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \vspace
        #0.75
    }
>>> abjad.show(markup) 

Returns new markup.


Read-only properties

contents

Gets contents of markup.

Initializes contents positionally:

>>> abjad.Markup('Allegro assai')
Markup(contents=['Allegro assai'])

Initializes contents from keyword:

>>> abjad.Markup(contents='Allegro assai')
Markup(contents=['Allegro assai'])
Return type:List[Union[str, MarkupCommand]]
direction

Gets direction of markup.

Initializes without direction:

>>> abjad.Markup('Allegro')
Markup(contents=['Allegro'])

Initializes with direction:

>>> abjad.Markup('Allegro', direction=abjad.Up)
Markup(contents=['Allegro'], direction=Up)
Return type:Optional[VerticalAlignment]
literal

Is true when markup formats contents literally.

Adds neither quotes nor braces:

>>> string = r'\custom-function #1 #4'
>>> markup = abjad.Markup.from_literal(string, literal=True)
>>> abjad.f(markup)
\markup \custom-function #1 #4

Works with direction:

>>> string = r'\custom-function #1 #4'
>>> markup = abjad.Markup.from_literal(
...     string,
...     direction=abjad.Up,
...     literal=True,
...     )
>>> abjad.f(markup)
^ \markup \custom-function #1 #4
Return type:Optional[bool]
tweaks

Gets tweaks.

>>> markup = abjad.Markup('Allegro assai', direction=abjad.Up)
>>> markup = markup.bold()
>>> abjad.tweak(markup).color = 'blue'
>>> staff = abjad.Staff("c'4 d' e' f'")
>>> abjad.attach(markup, staff[0])
>>> abjad.f(staff)
\new Staff
{
    c'4
    - \tweak color #blue
    ^ \markup {
        \bold
            "Allegro assai"
        }
    d'4
    e'4
    f'4
}
>>> abjad.show(staff) 
>>> markup = abjad.Markup(
...     'Allegro assai',
...     direction=abjad.Up,
...     tweaks=[('color', 'blue')],
...     )
>>> markup = markup.bold()
>>> staff = abjad.Staff("c'4 d' e' f'")
>>> abjad.attach(markup, staff[0])
>>> abjad.f(staff)
\new Staff
{
    c'4
    - \tweak color #blue
    ^ \markup {
        \bold
            "Allegro assai"
        }
    d'4
    e'4
    f'4
}
>>> abjad.show(staff) 
Return type:Optional[LilyPondTweakManager]
class abjad.markups.MarkupCommand(name=None, *arguments)

LilyPond markup command.

Initializes a complex LilyPond markup command:

>>> circle = abjad.MarkupCommand('draw-circle', 2.5, 0.1, False)
>>> square = abjad.MarkupCommand('rounded-box', 'hello?')
>>> line = abjad.MarkupCommand('line', [square, 'wow!'])
>>> rotate = abjad.MarkupCommand('rotate', 60, line)
>>> combine = abjad.MarkupCommand('combine', rotate, circle)
>>> print(format(combine, 'lilypond'))
\combine
    \rotate
        #60
        \line
            {
                \rounded-box
                    hello?
                wow!
            }
    \draw-circle
        #2.5
        #0.1
        ##f
>>> note = abjad.Note("c'4")
>>> markup = abjad.Markup(combine)
>>> abjad.attach(markup, note)
>>> abjad.show(note) 

Works with the LilyPond \score markup command:

>>> small_staff = abjad.Staff("fs'16 gs'16 as'16 b'16")
>>> small_staff.remove_commands.append('Clef_engraver')
>>> small_staff.remove_commands.append('Time_signature_engraver')
>>> abjad.setting(small_staff).font_size = -3
>>> layout_block = abjad.Block(name='layout')
>>> layout_block.indent = 0
>>> layout_block.ragged_right = True
>>> command = abjad.MarkupCommand(
...     'score',
...     [small_staff, layout_block],
...     )
>>> abjad.f(command)
\score
    {
        \new Staff
        \with
        {
            \remove Clef_engraver
            \remove Time_signature_engraver
            fontSize = #-3
        }
        {
            fs'16
            gs'16
            as'16
            b'16
        }
        \layout {
            indent = #0
            ragged-right = ##t
        }
    }
>>> markup = abjad.Markup(contents=command, direction=abjad.Up)
>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> abjad.attach(markup, staff[0])
>>> abjad.show(staff) 

Attributes Summary

__eq__ Is true when argument is a markup command with name and arguments equal to those of this markup command.
__format__ Formats markup command.
__hash__ Hashes markup command.
__repr__ Gets markup command interpreter representation.
__str__ Gets string representation of markup command.
arguments Gets markup command arguments.
combine_markup_commands Combines markup command and / or strings.
deactivate Is true when markup command deactivates tag.
force_quotes Is true when markup command should force quotes around arguments.
name Gets markup command name.
tag Gets tag.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a markup command with name and arguments equal to those of this markup command.

>>> command_1 = abjad.MarkupCommand('bold', 'foo')
>>> command_2 = abjad.MarkupCommand('bold', 'foo')
>>> command_3 = abjad.MarkupCommand('bold', 'bar')
>>> command_1 == command_1
True
>>> command_1 == command_2
True
>>> command_1 == command_3
False
>>> command_2 == command_1
True
>>> command_2 == command_2
True
>>> command_2 == command_3
False
>>> command_3 == command_1
False
>>> command_3 == command_2
False
>>> command_3 == command_3
True

Returns true or false.

__format__(format_specification='')

Formats markup command.

Prints storage format:

>>> circle = abjad.MarkupCommand('draw-circle', 2.5, 0.1, False)
>>> square = abjad.MarkupCommand('rounded-box', 'hello?')
>>> line = abjad.MarkupCommand('line', [square, 'wow!'])
>>> rotate = abjad.MarkupCommand('rotate', 60, line)
>>> combine = abjad.MarkupCommand('combine', rotate, circle)
>>> print(format(combine, 'storage'))
abjad.MarkupCommand(
    'combine',
    abjad.MarkupCommand(
        'rotate',
        60,
        abjad.MarkupCommand(
            'line',
            [
                abjad.MarkupCommand(
                    'rounded-box',
                    'hello?'
                    ),
                'wow!',
                ]
            )
        ),
    abjad.MarkupCommand(
        'draw-circle',
        2.5,
        0.1,
        False
        )
    )

Prints LilyPond format:

>>> circle = abjad.MarkupCommand('draw-circle', 2.5, 0.1, False)
>>> square = abjad.MarkupCommand('rounded-box', 'hello?')
>>> line = abjad.MarkupCommand('line', [square, 'wow!'])
>>> rotate = abjad.MarkupCommand('rotate', 60, line)
>>> combine = abjad.MarkupCommand('combine', rotate, circle)
>>> print(format(combine, 'lilypond'))
\combine
    \rotate
        #60
        \line
            {
                \rounded-box
                    hello?
                wow!
            }
    \draw-circle
        #2.5
        #0.1
        ##f

Set format_specification to '', 'lilypond' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

__hash__()

Hashes markup command.

Redefined in tandem with __eq__.

__repr__()

Gets markup command interpreter representation.

Interpreter representation is evaluable.

>>> command = abjad.MarkupCommand('hspace', 0)
>>> command
abjad.MarkupCommand(
    'hspace',
    0
    )
>>> eval(repr(command))
abjad.MarkupCommand(
    'hspace',
    0
    )

Returns string.

__str__()

Gets string representation of markup command.

>>> circle = abjad.MarkupCommand('draw-circle', 2.5, 0.1, False)
>>> square = abjad.MarkupCommand('rounded-box', 'hello?')
>>> line = abjad.MarkupCommand('line', [square, 'wow!'])
>>> rotate = abjad.MarkupCommand('rotate', 60, line)
>>> combine = abjad.MarkupCommand('combine', rotate, circle)
>>> print(str(combine))
\combine
    \rotate
        #60
        \line
            {
                \rounded-box
                    hello?
                wow!
            }
    \draw-circle
        #2.5
        #0.1
        ##f

Returns string.


Class & static methods

static combine_markup_commands(*commands)

Combines markup command and / or strings.

LilyPond’s ‘combine’ markup command can only take two arguments, so in order to combine more than two stencils, a cascade of ‘combine’ commands must be employed. combine_markup_commands simplifies this process.

>>> markup_a = abjad.MarkupCommand(
...     'draw-circle',
...     4,
...     0.4,
...     False,
...     )
>>> markup_b = abjad.MarkupCommand(
...     'filled-box',
...     abjad.SchemePair((-4, 4)),
...     abjad.SchemePair((-0.5, 0.5)),
...     1,
...     )
>>> markup_c = "some text"
>>> markup = abjad.MarkupCommand.combine_markup_commands(
...     markup_a,
...     markup_b,
...     markup_c,
...     )
>>> result = format(markup, 'lilypond')
>>> print(result)
\combine
    \combine
        \draw-circle
            #4
            #0.4
            ##f
        \filled-box
            #'(-4 . 4)
            #'(-0.5 . 0.5)
            #1
    "some text"

Returns a markup command instance, or a string if that was the only argument.


Read/write properties

deactivate

Is true when markup command deactivates tag.

Returns true, false or none.

force_quotes

Is true when markup command should force quotes around arguments.

Here’s a markup command formatted in the usual way without forced quotes:

>>> lines = ['foo', 'bar blah', 'baz']
>>> command = abjad.MarkupCommand('column', lines)
>>> markup = abjad.Markup(command)
>>> abjad.f(markup)
\markup {
    \column
        {
            foo
            "bar blah"
            baz
        }
    }

The markup command forces quotes around only the spaced string 'bar blah'.

Here’s the same markup command with forced quotes:

>>> lines = ['foo', 'bar blah', 'baz']
>>> command = abjad.MarkupCommand('column', lines)
>>> command.force_quotes = True
>>> markup = abjad.Markup(command)
>>> abjad.f(markup)
\markup {
    \column
        {
            "foo"
            "bar blah"
            "baz"
        }
    }

The markup command forces quotes around all strings.

The rendered result of forced and unforced quotes is the same.

Defaults to false.

Returns true or false.

tag

Gets tag.


Read-only properties

arguments

Gets markup command arguments.

>>> arguments = ('draw-circle', 1, 0.1, False)
>>> command = abjad.MarkupCommand(*arguments)
>>> command.arguments
(1, 0.1, False)

Returns tuple.

name

Gets markup command name.

>>> arguments = ('draw-circle', 1, 0.1, False)
>>> command = abjad.MarkupCommand(*arguments)
>>> command.name
'draw-circle'

Returns string.

class abjad.markups.MarkupList(items=None, item_class=None, keep_sorted=None)

Markup list.

Initializes from strings:

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(markups)
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Attributes Summary

__contains__ Is true when markup markup list contains item.
__format__ Formats markup list.
__iadd__ Changes items in argument to items and extends markup list.
__illustrate__ Illustrates markup markup list.
__setitem__ Sets item i equal to argument.
append Appends item to markup list.
center_column LilyPond \center-column markup command.
column LilyPond \column markup command.
combine LilyPond \combine markup command.
concat LilyPond \concat markup command.
count Counts item in markup list.
extend Extends markup list with items.
index Gets index of item in markup list.
insert Inserts item in markup markup list.
item_class Gets markup list item class.
items Gets markup list items.
keep_sorted Is true when markup list keeps markups sorted.
left_column LilyPond \left-column markup command.
line LilyPond \line markup command.
overlay LilyPond \overlay markup command.
pop Pops item i from markup list.
remove Removes item from markup list.
right_column LilyPond \right-column markup command.

Special methods

__contains__(item)

Is true when markup markup list contains item.

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(markups)
>>> 'assai' in markup_list
True

Returns true or false.

(TypedList).__delitem__(i)

Aliases list.__delitem__().

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection.

Returns true or false.

__format__(format_specification='')

Formats markup list.

Formats markup list:

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(markups)
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )

Returns string.

(TypedList).__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

(TypedCollection).__hash__()

Hashes typed collection.

Redefined in tandem with __eq__.

__iadd__(argument)

Changes items in argument to items and extends markup list.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list += ['ma', 'non', 'troppo']
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        abjad.Markup(
            contents=['ma'],
            ),
        abjad.Markup(
            contents=['non'],
            ),
        abjad.Markup(
            contents=['troppo'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns none.

__illustrate__()

Illustrates markup markup list.

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(markups)
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedList).__reversed__()

Aliases list.__reversed__().

Returns generator.

__setitem__(i, argument)

Sets item i equal to argument.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list[-1] = 'non troppo'
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['non troppo'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns none.


Methods

append(item)

Appends item to markup list.

>>> markup_list = abjad.MarkupList(['Allegro'])
>>> markup_list.append('assai')
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns none.

center_column(direction=None)

LilyPond \center-column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markups = [city, date]
>>> markup_list = abjad.MarkupList(markups)
>>> markup = markup_list.center_column(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

(MutableSequence).clear() → None -- remove all items from S
column(direction=None)

LilyPond \column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup_list = abjad.MarkupList([city, date])
>>> markup = markup_list.column()
>>> abjad.f(markup)
\markup {
    \column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

combine(direction=None)

LilyPond \combine markup command.

>>> markup_one = abjad.Markup('Allegro assai')
>>> markup_two = abjad.Markup.draw_line(13, 0)
>>> markup_list = [markup_one, markup_two]
>>> markup_list = abjad.MarkupList(markup_list)
>>> markup = markup_list.combine(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \combine
        "Allegro assai"
        \draw-line
            #'(13 . 0)
    }
>>> abjad.show(markup) 

Returns new markup.

concat(direction=None)

LilyPond \concat markup command.

>>> downbow = abjad.Markup.musicglyph('scripts.downbow')
>>> hspace = abjad.Markup.hspace(1)
>>> upbow = abjad.Markup.musicglyph('scripts.upbow')
>>> markups = [downbow, hspace, upbow]
>>> markup_list = abjad.MarkupList(markups)
>>> markup = markup_list.concat(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \concat
        {
            \musicglyph
                #"scripts.downbow"
            \hspace
                #1
            \musicglyph
                #"scripts.upbow"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

count(item)

Counts item in markup list.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> abjad.show(markup_list) 
>>> markup_list.count('Allegro')
1
>>> markup_list.count('assai')
1
>>> markup_list.count('ma non troppo')
0

Returns none.

extend(items)

Extends markup list with items.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns none.

index(item)

Gets index of item in markup list.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> abjad.show(markup_list) 
>>> markup_list.index('Allegro')
0
>>> markup_list.index('assai')
1

Returns none.

insert(i, item)

Inserts item in markup markup list.

>>> markup_list = abjad.MarkupList(['assai'])
>>> markup_list.insert(0, 'Allegro')
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        abjad.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns markup class.

left_column(direction=None)

LilyPond \left-column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup_list = abjad.MarkupList([city, date])
>>> markup = markup_list.left_column()
>>> abjad.f(markup)
\markup {
    \left-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

line(direction=None)

LilyPond \line markup command.

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(markups)
>>> markup = markup_list.line()
>>> abjad.f(markup)
\markup {
    \line
        {
            Allegro
            assai
        }
    }
>>> abjad.show(markup) 

Returns new markup.

overlay(direction=None)

LilyPond \overlay markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup_list = abjad.MarkupList([city, date])
>>> markup = markup_list.overlay(direction=abjad.Up)
>>> abjad.f(markup)
^ \markup {
    \overlay
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

pop(i=-1)

Pops item i from markup list.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list.pop()
Markup(contents=['assai'])
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns none.

remove(item)

Removes item from markup list.

>>> markup_list = abjad.MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list.remove('assai')
>>> abjad.f(markup_list)
abjad.MarkupList(
    items=[
        abjad.Markup(
            contents=['Allegro'],
            ),
        ],
    )
>>> abjad.show(markup_list) 

Returns none.

(TypedList).reverse()

Reverses items in typed list.

right_column(direction=None)

LilyPond \right-column markup command.

>>> city = abjad.Markup('Los Angeles')
>>> date = abjad.Markup('May - August 2014')
>>> markup_list = abjad.MarkupList([city, date])
>>> markup = markup_list.right_column()
>>> abjad.f(markup)
\markup {
    \right-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> abjad.show(markup) 

Returns new markup.

(TypedList).sort(cmp=None, key=None, reverse=False)

Sorts items in typed list.


Read/write properties

keep_sorted

Is true when markup list keeps markups sorted.

Keeps markup sorted:

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(keep_sorted=True)
>>> markup_list.append('assai')
>>> markup_list.append('Allegro')
>>> abjad.show(markup_list) 

Does not keep markup sorted:

>>> markups = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList()
>>> markup_list.append('assai')
>>> markup_list.append('Allegro')
>>> abjad.show(markup_list) 

Defaults to none.

Set to true, false or none.

Returns true, false or none.


Read-only properties

item_class

Gets markup list item class.

>>> abjad.MarkupList().item_class
<class 'abjad.markups.Markup'>

Returns markup class.

items

Gets markup list items.

Initializes items positionally:

>>> items = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(items)
>>> for item in markup_list.items:
...     item
... 
Markup(contents=['Allegro'])
Markup(contents=['assai'])

Initializes items from keyword:

>>> items = ['Allegro', 'assai']
>>> markup_list = abjad.MarkupList(items=items)
>>> for item in markup_list.items:
...     item
... 
Markup(contents=['Allegro'])
Markup(contents=['assai'])

Returns tuple.

class abjad.markups.Postscript(operators=None)

Postscript session.

Note

The markup resulting from the \postscript markup command is both 0-height and 0-width. Make sure to wrap the \postscript command with a \pad-to-box or \with-dimensions markup command to give it explicit height and width. Likewise, use only positive coordinates in your postscript markup if at all possible. When specifying explicit extents with \pad-to-box or \with-dimensions, negative extents will not be interpreted by LilyPond as resulting in positive height or width, and may have unexpected behavior.

Note

LilyPond will fail to render if any of the font commands are used. To create text, use .show('text') preceded by .scale() or .rotate() to provide the appropriate transformation. .charpath() is also useable. However, .findfont(), .scalefont(), .setfont() will cause LilyPond to error.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.moveto(1, 1)
>>> postscript = postscript.setlinewidth(2.5)
>>> postscript = postscript.setdash((2, 1))
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('moveto', 1.0, 1.0),
        abjad.PostscriptOperator('setlinewidth', 2.5),
        abjad.PostscriptOperator('setdash', (2.0, 1.0), 0.0),
        abjad.PostscriptOperator('lineto', 3.0, -4.0),
        abjad.PostscriptOperator('stroke'),
        ),
    )
>>> print(str(postscript))
1 1 moveto
2.5 setlinewidth
[ 2 1 ] 0 setdash
3 -4 lineto
stroke
>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(0, 0)
>>> postscript = postscript.rlineto(0, -10)
>>> postscript = postscript.rlineto(10, 0)
>>> postscript = postscript.rlineto(0, 10)
>>> postscript = postscript.rlineto(-10, 0)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setrgbcolor(0.5, 1, 0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setrgbcolor(1, 0, 0)
>>> postscript = postscript.setlinewidth(1)
>>> postscript = postscript.stroke()
>>> abjad.show(postscript) 

Attributes Summary

__add__ Adds postscript to argument.
__illustrate__ Illustrates Postscript.
__radd__ Adds argument to postscript.
__str__ Gets string representation of Postscript.
as_markup Converts postscript to markup.
charpath Postscript charpath operator.
closepath Postscript closepath operator.
curveto Postscript curveto operator.
fill Postscript fill operator.
findfont Postscript findfont operator.
grestore Postscript grestore operator.
gsave Postscript gsave operator.
lineto Postscript lineto operator.
moveto Postscript moveto operator.
newpath Postscript newpath operator.
operators Gets Postscript operators.
rcurveto Postscript rcurveto operator.
rlineto Postscript rlineto operator.
rmoveto Postscript rmoveto operator.
rotate Postscript restore operator.
scale Postscript scale operator.
scalefont Postscript scalefont operator.
setdash Postscript setdash operator.
setfont Postscript setfont operator.
setgray Postscript setgray operator.
setlinewidth Postscript setlinewidth operator.
setrgbcolor Postscript setrgb operator.
show Postscript show operator.
stroke Postscript stroke operator.
translate Postscript translate operator.

Special methods

__add__(argument)

Adds postscript to argument.

Returns new postscript.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

__illustrate__()

Illustrates Postscript.

Returns LilyPond file.

__radd__(argument)

Adds argument to postscript.

Returns new postscript.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of Postscript.

Return string.


Methods

as_markup()

Converts postscript to markup.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> markup = postscript.as_markup()
>>> print(format(markup))
\markup {
    \postscript
        #"
        newpath
        100 200 moveto
        200 250 lineto
        100 300 lineto
        closepath
        gsave
        0.5 setgray
        fill
        grestore
        4 setlinewidth
        0.75 setgray
        stroke
        "
    }

Returns new markup.

charpath(text, modify_font=True)

Postscript charpath operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(32)
>>> postscript = postscript.setfont()
>>> postscript = postscript.translate(100, 200)
>>> postscript = postscript.rotate(45)
>>> postscript = postscript.scale(2, 1)
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(0, 0)
>>> postscript = postscript.charpath('This is text.', True)
>>> postscript = postscript.setlinewidth(0.5)
>>> postscript = postscript.setgray(0.25)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
/Times-Roman findfont
32 scalefont
setfont
100 200 translate
45 rotate
2 1 scale
newpath
0 0 moveto
(This is text.) true charpath
0.5 setlinewidth
0.25 setgray
stroke

Returns new Postscript.

closepath()

Postscript closepath operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 200 moveto
200 250 lineto
100 300 lineto
closepath
gsave
0.5 setgray
fill
grestore
4 setlinewidth
0.75 setgray
stroke

Returns new Postscript.

curveto(x1, y1, x2, y2, x3, y3)

Postscript curveto operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.curveto(0, 1, 1.5, 2, 3, 6)
>>> print(str(postscript))
0 1 1.5 2 3 6 curveto

Returns new Postscript.

fill()

Postscript fill operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 200 moveto
200 250 lineto
100 300 lineto
closepath
gsave
0.5 setgray
fill
grestore
4 setlinewidth
0.75 setgray
stroke

Returns new Postscript.

findfont(font_name)

Postscript findfont operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(12)
>>> postscript = postscript.setfont()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.show('This is text.')
>>> print(str(postscript))
/Times-Roman findfont
12 scalefont
setfont
newpath
100 200 moveto
(This is text.) show

Returns new Postscript.

grestore()

Postscript grestore operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 200 moveto
200 250 lineto
100 300 lineto
closepath
gsave
0.5 setgray
fill
grestore
4 setlinewidth
0.75 setgray
stroke

Returns new Postscript.

gsave()

Postscript gsave operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 200 moveto
200 250 lineto
100 300 lineto
closepath
gsave
0.5 setgray
fill
grestore
4 setlinewidth
0.75 setgray
stroke

Returns new Postscript.

lineto(x, y)

Postscript lineto operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.moveto(1, 1)
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
1 1 moveto
3 -4 lineto
stroke

Returns new Postscript.

moveto(x, y)

Postscript moveto operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.moveto(1, 1)
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('moveto', 1.0, 1.0),
        abjad.PostscriptOperator('lineto', 3.0, -4.0),
        abjad.PostscriptOperator('stroke'),
        ),
    )
>>> print(str(postscript))
1 1 moveto
3 -4 lineto
stroke

Returns new Postscript.

newpath()

Postscript newpath operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 200 moveto
200 250 lineto
100 300 lineto
closepath
gsave
0.5 setgray
fill
grestore
4 setlinewidth
0.75 setgray
stroke

Returns new Postscript.

rcurveto(dx1, dy1, dx2, dy2, dx3, dy3)

Postscript rcurveto operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.rcurveto(0, 1, 1.5, 2, 3, 6)
>>> print(str(postscript))
0 1 1.5 2 3 6 rcurveto

Returns new Postscript.

rlineto(dx, dy)

Postscript rlineto operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.rmoveto(1, 1)
>>> postscript = postscript.rlineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('rmoveto', 1.0, 1.0),
        abjad.PostscriptOperator('rlineto', 3.0, -4.0),
        abjad.PostscriptOperator('stroke'),
        ),
    )
>>> print(str(postscript))
1 1 rmoveto
3 -4 rlineto
stroke

Returns new Postscript.

rmoveto(dx, dy)

Postscript rmoveto operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.rmoveto(1, 1)
>>> postscript = postscript.rlineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('rmoveto', 1.0, 1.0),
        abjad.PostscriptOperator('rlineto', 3.0, -4.0),
        abjad.PostscriptOperator('stroke'),
        ),
    )
>>> print(str(postscript))
1 1 rmoveto
3 -4 rlineto
stroke

Returns new Postscript.

rotate(degrees)

Postscript restore operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(32)
>>> postscript = postscript.setfont()
>>> postscript = postscript.translate(100, 200)
>>> postscript = postscript.rotate(45)
>>> postscript = postscript.scale(2, 1)
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(0, 0)
>>> postscript = postscript.charpath('This is text.', True)
>>> postscript = postscript.setlinewidth(0.5)
>>> postscript = postscript.setgray(0.25)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
/Times-Roman findfont
32 scalefont
setfont
100 200 translate
45 rotate
2 1 scale
newpath
0 0 moveto
(This is text.) true charpath
0.5 setlinewidth
0.25 setgray
stroke

Returns new Postscript.

scale(dx, dy)

Postscript scale operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(32)
>>> postscript = postscript.setfont()
>>> postscript = postscript.translate(100, 200)
>>> postscript = postscript.rotate(45)
>>> postscript = postscript.scale(2, 1)
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(0, 0)
>>> postscript = postscript.charpath('This is text.', True)
>>> postscript = postscript.setlinewidth(0.5)
>>> postscript = postscript.setgray(0.25)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
/Times-Roman findfont
32 scalefont
setfont
100 200 translate
45 rotate
2 1 scale
newpath
0 0 moveto
(This is text.) true charpath
0.5 setlinewidth
0.25 setgray
stroke

Returns new Postscript.

scalefont(font_size)

Postscript scalefont operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(12)
>>> postscript = postscript.setfont()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.show('This is text.')
>>> print(str(postscript))
/Times-Roman findfont
12 scalefont
setfont
newpath
100 200 moveto
(This is text.) show

Returns new Postscript.

setdash(array=None, offset=0)

Postscript setdash operator.

>>> postscript = abjad.Postscript().setdash([2, 1], 3)
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('setdash', (2.0, 1.0), 3.0),
        ),
    )
>>> print(str(postscript))
[ 2 1 ] 3 setdash
>>> postscript = abjad.Postscript().setdash()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('setdash', (), 0.0),
        ),
    )
>>> print(str(postscript))
[ ] 0 setdash

Returns new Postscript.

setfont()

Postscript setfont operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(12)
>>> postscript = postscript.setfont()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.show('This is text.')
>>> print(str(postscript))
/Times-Roman findfont
12 scalefont
setfont
newpath
100 200 moveto
(This is text.) show

Returns new Postscript.

setgray(gray_value)

Postscript setgray operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.lineto(200, 250)
>>> postscript = postscript.lineto(100, 300)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setgray(0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.setgray(0.75)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 200 moveto
200 250 lineto
100 300 lineto
closepath
gsave
0.5 setgray
fill
grestore
4 setlinewidth
0.75 setgray
stroke

Returns new Postscript.

setlinewidth(width)

Postscript setlinewidth operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.moveto(1, 1)
>>> postscript = postscript.setlinewidth(2.5)
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('moveto', 1.0, 1.0),
        abjad.PostscriptOperator('setlinewidth', 2.5),
        abjad.PostscriptOperator('lineto', 3.0, -4.0),
        abjad.PostscriptOperator('stroke'),
        ),
    )
>>> print(str(postscript))
1 1 moveto
2.5 setlinewidth
3 -4 lineto
stroke

Returns new Postscript.

setrgbcolor(red, green, blue)

Postscript setrgb operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 100)
>>> postscript = postscript.rlineto(0, 100)
>>> postscript = postscript.rlineto(100, 0)
>>> postscript = postscript.rlineto(0, -100)
>>> postscript = postscript.rlineto(-100, 0)
>>> postscript = postscript.closepath()
>>> postscript = postscript.gsave()
>>> postscript = postscript.setrgbcolor(0.5, 1, 0.5)
>>> postscript = postscript.fill()
>>> postscript = postscript.grestore()
>>> postscript = postscript.setrgbcolor(1, 0, 0)
>>> postscript = postscript.setlinewidth(4)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
newpath
100 100 moveto
0 100 rlineto
100 0 rlineto
0 -100 rlineto
-100 0 rlineto
closepath
gsave
0.5 1 0.5 setrgbcolor
fill
grestore
1 0 0 setrgbcolor
4 setlinewidth
stroke

Returns new Postscript.

show(text)

Postscript show operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(12)
>>> postscript = postscript.setfont()
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(100, 200)
>>> postscript = postscript.show('This is text.')
>>> print(str(postscript))
/Times-Roman findfont
12 scalefont
setfont
newpath
100 200 moveto
(This is text.) show

Returns new Postscript.

stroke()

Postscript stroke operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> print(format(postscript))
abjad.Postscript(
    operators=(
        abjad.PostscriptOperator('lineto', 3.0, -4.0),
        abjad.PostscriptOperator('stroke'),
        ),
    )
>>> print(str(postscript))
3 -4 lineto
stroke

Returns new Postscript.

translate(dx, dy)

Postscript translate operator.

>>> postscript = abjad.Postscript()
>>> postscript = postscript.findfont('Times Roman')
>>> postscript = postscript.scalefont(32)
>>> postscript = postscript.setfont()
>>> postscript = postscript.translate(100, 200)
>>> postscript = postscript.rotate(45)
>>> postscript = postscript.scale(2, 1)
>>> postscript = postscript.newpath()
>>> postscript = postscript.moveto(0, 0)
>>> postscript = postscript.charpath('This is text.', True)
>>> postscript = postscript.setlinewidth(0.5)
>>> postscript = postscript.setgray(0.25)
>>> postscript = postscript.stroke()
>>> print(str(postscript))
/Times-Roman findfont
32 scalefont
setfont
100 200 translate
45 rotate
2 1 scale
newpath
0 0 moveto
(This is text.) true charpath
0.5 setlinewidth
0.25 setgray
stroke

Returns new Postscript.


Read-only properties

operators

Gets Postscript operators.

Returns tuple or none.

class abjad.markups.PostscriptOperator(name='stroke', *arguments)

Postscript operator.

>>> operator = abjad.PostscriptOperator('rmoveto', 1, 1.5)
>>> print(format(operator))
abjad.PostscriptOperator('rmoveto', 1, 1.5)

Attributes Summary

__str__ Gets string representation of Postscript operator.
arguments Gets Postscript operator arguments.
name Gets Postscript operator name.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of Postscript operator.

>>> operator = abjad.PostscriptOperator('rmoveto', 1, 1.5)
>>> str(operator)
'1 1.5 rmoveto'

Returns string.


Read-only properties

arguments

Gets Postscript operator arguments.

Returns tuple or none.

name

Gets Postscript operator name.

Returns string.