Base Class for Character-Based Art¶
This is the common base class for
sage.typeset.ascii_art.AsciiArt
and
sage.typeset.unicode_art.UnicodeArt
. They implement simple
graphics by placing characters on a rectangular grid, in other words,
using monospace fonts. The difference is that one is restricted to
7-bit ascii, the other uses all unicode code points.
- class sage.typeset.character_art.CharacterArt(lines=[], breakpoints=[], baseline=None)[source]¶
Bases:
SageObject
Abstract base class for character art.
INPUT:
lines
– the list of lines of the representation of the character art objectbreakpoints
– the list of points where the representation can be splitbaseline
– the reference line (from the bottom)
Instead of just integers,
breakpoints
may also contain tuples consisting of an offset and the breakpoints of a nested substring at that offset. This is used to prioritize the breakpoints, as line breaks inside the substring will be avoided if possible.EXAMPLES:
sage: i = var('i') # needs sage.symbolic sage: ascii_art(sum(pi^i/factorial(i)*x^i, i, 0, oo)) # needs sage.symbolic pi*x e
- classmethod empty()[source]¶
Return the empty character art object.
EXAMPLES:
sage: from sage.typeset.ascii_art import AsciiArt sage: AsciiArt.empty()
- get_baseline()[source]¶
Return the line where the baseline is, for example:
5 4 14*x + 5*x
the baseline has at line
and{ o } { \ : 4 } { o }
has at line
.
- split(pos)[source]¶
Split the representation at the position
pos
.EXAMPLES:
sage: from sage.typeset.ascii_art import AsciiArt sage: p3 = AsciiArt([" * ", "***"]) sage: p5 = AsciiArt([" * ", " * * ", "*****"]) sage: aa = ascii_art([p3, p5]) sage: a,b= aa.split(6) sage: a [ [ * [ ***, sage: b * ] * * ] ***** ]