raart: Racket ASCII Art and Interfaces
(require raart) | package: raart |
The raart module provides an algebraic model of ASCII that can be used for art, user interfaces, and diagrams. It is comparable to 2htdp/image.
Check out some examples in the test directory in the source.
1 Buffers
(require raart/buffer) | package: raart |
When drawing, raart renders to a buffer. In almost all circumstances, you should use make-cached-buffer.
procedure
(make-output-buffer [#:output output]) → buffer?
output : output-port? = (current-output-port)
procedure
(make-terminal-buffer rows cols [ #:clear? clear? #:output output]) → buffer? rows : exact-nonnegative-integer? cols : exact-nonnegative-integer? clear? : boolean? = #t output : output-port? = (current-output-port)
procedure
(make-cached-buffer rows cols [ #:output output]) → buffer? rows : exact-nonnegative-integer? cols : exact-nonnegative-integer? output : output-port? = (current-output-port)
2 Drawing
(require raart/draw) | package: raart |
raart represents ASCII art algebraically as an abstract raart? object.
procedure
x : raart?
procedure
x : raart?
procedure
(with-drawing s fc bc r) → raart?
s : (or/c style/c #f) fc : (or/c color/c #f) bc : (or/c color/c #f) r : raart?
procedure
w : exact-nonnegative-integer? = 0 h : exact-nonnegative-integer? = 0
procedure
w : exact-nonnegative-integer?
procedure
h : exact-nonnegative-integer?
procedure
(vappend2 y x [ #:halign halign #:reverse? reverse?]) → raart? y : raart? x : raart?
halign :
(or/c halign/c #f) = #f reverse? : boolean? = #f
> (draw-here (vappend2 (text "Hello") (text "World")))
[0mWorld
Hello
> (draw-here (vappend2 (text "Short") (text "Very Very Long"))) *vappend2: Widths must be equal: 14 vs 5
> (draw-here (vappend2 (text "Short") (text "Very Very Long") #:halign 'left))
[0mVery Very Long
Short
> (draw-here (vappend2 (text "Short") (text "Very Very Long") #:halign 'right))
[0mVery Very Long
Short
> (draw-here (vappend2 (text "Short") (text "Very Very Long") #:halign 'center))
[0mVery Very Long
Short
procedure
(vappend y x ... [ #:halign halign #:reverse? reverse?]) → raart? y : raart? x : raart?
halign :
(or/c halign/c #f) = #f reverse? : boolean? = #f
> (draw-here (vappend (text "Short") (text "A Little Medium") (text "Very Very Long") #:halign 'right))
[0m Short
A Little Medium
Very Very Long
procedure
(vappend* y-and-xs [ #:halign halign #:reverse? reverse?]) → raart? y-and-xs : (non-empty-listof raart?) halign : (or/c halign/c #f) = #f reverse? : boolean? = #f
> (draw-here (vappend* (list (text "Short") (text "A Little Medium") (text "Very Very Long")) #:halign 'right))
[0m Short
A Little Medium
Very Very Long
procedure
(happend2 y x [ #:valign valign #:reverse? reverse?]) → raart? y : raart? x : raart?
valign :
(or/c valign/c #f) = #f reverse? : boolean? = #f
> (draw-here (happend2 (vline 2) (vline 2)))
[0m││
││
> (draw-here (happend2 (vline 2) (vline 4))) *happend2: Heights must be equal: 4 vs 2
> (draw-here (happend2 (vline 2) (vline 4) #:valign 'top))
[0m││
││
│
│
> (draw-here (happend2 (vline 2) (vline 4) #:valign 'center))
[0m│
││
││
│
> (draw-here (happend2 (vline 2) (vline 4) #:valign 'bottom))
[0m│
│
││
││
procedure
(happend y x ... [ #:valign valign #:reverse? reverse?]) → raart? y : raart? x : raart?
valign :
(or/c valign/c #f) = #f reverse? : boolean? = #f
procedure
(happend* y-and-xs [ #:valign valign #:reverse? reverse?]) → raart? y-and-xs : (non-empty-listof raart?) valign : (or/c valign/c #f) = #f reverse? : boolean? = #f
procedure
max-width : exact-nonnegative-integer? s : string? halign : halign/c = 'left
> (draw-here (para 45 "And it came to pass that I, Nephi, said unto my father: I will go and do the things which the Lord hath commanded, for I know that the Lord giveth no commandments unto the children of men, save he shall prepare a way for them that they may accomplish the thing which he commandeth them."))
[0m And it came to pass that I, Nephi, said unto
my father: I will go and do the things which
the Lord hath commanded, for I know that the
Lord giveth no commandments unto the children
of men, save he shall prepare a way for them
that they may accomplish the thing which he
commandeth them.
procedure
(para* max-width rs [ #:halign halign #:gap gap]) → raart? max-width : exact-nonnegative-integer? rs : (listof raart?) halign : halign/c = 'left gap : raart? = (blank)
procedure
back : raart? dr : exact-nonnegative-integer? dh : exact-nonnegative-integer? front : raart?
syntax
(place-at* back [dr dc fore] ...)
back : raart?
dr : exact-nonnegative-integer?
dc : exact-nonnegative-integer?
fore : raart?
procedure
mw : exact-nonnegative-integer? mh : exact-nonnegative-integer? c : exact-nonnegative-integer? r : exact-nonnegative-integer? x : raart?
procedure
dr : exact-nonnegative-integer? dc : exact-nonnegative-integer? x : raart?
procedure
w : exact-nonnegative-integer? h : exact-nonnegative-integer? halign : halign/c = 'center valign : valign/c = 'center x : raart?
procedure
dw : exact-nonnegative-integer? dh : exact-nonnegative-integer? x : raart?
procedure
mc : exact-nonnegative-integer? mw : exact-nonnegative-integer? mr : exact-nonnegative-integer? mh : exact-nonnegative-integer? x : raart?
procedure
cc : exact-nonnegative-integer? cw : exact-nonnegative-integer? cr : exact-nonnegative-integer? ch : exact-nonnegative-integer? x : raart?
procedure
(table cells [ #:frames? frames? #:style s #:fg f #:bg b #:inset-dw dw #:inset-dh dh #:valign row-valign #:halign halign]) → raart? cells : (listof (listof raart?)) frames? : boolean? = #t s : (or/c style/c #f) = #f
f :
(or/c color/c #f) = #f b : (or/c color/c #f) = #f dw : exact-nonnegative-integer? = 0 dh : exact-nonnegative-integer? = 0 row-valign : valign/c = 'top
halign :
(or/c halign/c (list*of halign/c (or/c halign/c '()))) = 'left
procedure
f :
(-> exact-nonnegative-integer? exact-nonnegative-integer? exact-nonnegative-integer? exact-nonnegative-integer? any) x : raart?
procedure
(place-cursor-after x cr ch) → raart?
x : raart? cr : exact-nonnegative-integer? ch : exact-nonnegative-integer?
procedure
(without-cursor x) → raart?
x : raart?
3 lux integration
(require raart/lux-chaos) | package: raart |
raart provides integration with lux via the ansi module.
procedure
(make-raart [#:mouse? mouse?]) → chaos?
mouse? : boolean? = #f
The values that word-event is called with are characters or screen-size-report structures. If mouse? is non-false, then any-mouse-event, mouse-focus-event, or mouse-event structures may also be provided.
The values that word-output should return are raart? objects. The drawing will use make-cached-buffer to optimize the display process.