Base Class for Character-Based Art¶
This is the common base class for
sage.typeset.ascii_art.AsciiArt
and
sage.typeset.ascii_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)¶ Bases:
sage.structure.sage_object.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)
EXAMPLES:
sage: i = var('i') sage: ascii_art(sum(pi^i/factorial(i)*x^i, i, 0, oo)) pi*x e
-
classmethod
empty
()¶ Return the empty character art object
EXAMPLES:
sage: from sage.typeset.ascii_art import AsciiArt sage: AsciiArt.empty()
-
get_baseline
()¶ Return the line where the baseline is, for example:
5 4 14*x + 5*x
the baseline has at line \(0\) and
{ o } { \ : 4 } { o }
has at line \(1\).
-
get_breakpoints
()¶ Return an iterator of breakpoints where the object can be split.
For example the expression:
5 4 14x + 5x
can be split on position 4 (on the
+
).EXAMPLES:
sage: from sage.typeset.ascii_art import AsciiArt sage: p3 = AsciiArt([" * ", "***"]) sage: p5 = AsciiArt([" * ", " * * ", "*****"]) sage: aa = ascii_art([p3, p5]) sage: aa.get_breakpoints() [6]
-
height
()¶ Return the height of the ASCII art object.
OUTPUT:
Integer. The number of lines.
-
split
(pos)¶ 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 * ] * * ] ***** ]
-
width
()¶ Return the length (width) of the ASCII art object.
OUTPUT:
Integer. The number of characters in each line.