@HHHHHHHHHHRHHUHHU2U2223]V]3]MMMMMMMMWMW;W;mFFFF~E^!=))))===
HVHVHHVHHHHH2H22*]32]]3]]MMMM]M]MWWmWmmEFE^E~E~!!=)+!=+=:;;:
HHH                                                      #W#
HHH        AAlib-Ruby: Graphics for Text Terminals       WXO
U2U                                                      uuu
22]  AAlib-Ruby provides a graphics context rendered as  =+=
2]]  ascii-art and keyboard and mouse input via a        ===
]MM  number of text-only display drivers such as         .::
MMM  Curses, SLang, and X11.                             : .
MWW                                                         
mWm  AAlib-Ruby is a DL based wrapper around the AA-lib     
FE^  C library (http://aa-project.sf.net/aalib).            
~E^                                                         
!~+~~~;:;=;::Wu::W3QQ=+]]u= .]  +    =+:+]                  
)+====:::W:WQ#X3Xuu+u++=:+:::::. .                          
                                                            
          :::               .::.               :::          
       :_awxmx.+          ._wwWg_.:         :_awxmx.+       
      =j%XX%x&o:+        .xOH3%]3)Q        =j%XX%x&o:+      
      uxQ!]L0X/:3       ::*#]]JH()#:       uxQ!]L0X/:3      
      =-?O~"3:;]+        #?3/"!(~-u        =-?O~"3:;]+      
       +#:;;;-u:          +X;;;-:+.         +#:;;;-u:       
          ::.               .::.               ::.          

	Download        Documentation        Support


         Author:  Patrick Mahoney; Copyright © 2007
         Offered under GPLv2 or Ruby license

Usage

First, AA-lib must be initialized with AAlib.init or AAlib.autoinit, returning an AAlib::Context. Two buffers are maintained: the image buffer and the text buffer. AAlib::Context#putpixel is the primary method to draw on the image buffer. AAlib::Context#render converts the image buffer to text, writing the result to the text buffer. Text may be written directly to the text buffer using AAlib::Context#puts and similar. Note that text written this way may be overwritten after a call to AAlib::Context#render. Finally, AAlib::Context#flush writes the text buffer to the screen.

Example

require 'aalib' hp = AAlib::HardwareParams.new rp = AAlib::RenderParams.new AAlib.parseoptions(hp, rp) or abort AAlib.help aa = AAlib.autoinit(hp) or abort "failed to initialize AA-lib" begin aa.autoinitkbd # set up keyboard support # Fill screen with diagonal gradient width = aa.imgwidth height = aa.imgheight height.times do |y| width.times do |x| aa.putpixel(x, y, 127*(x.to_f/width) + 127*(y.to_f/height)) end end rp.randomval = 25 aa.render(rp) # converts image buffer to ascii-art msg = ' AA-lib: the ascii-art library ' blank = ' ' * msg.size attr = AAlib::Attr::BOLD col = (aa.scrwidth - msg.size)/2 row = aa.scrheight/2 aa.puts(col, row - 1, attr, blank) aa.puts(col, row, attr, msg) aa.puts(col, row + 1, attr, blank) aa.flush aa.getkey # wait for any key to exit ensure aa.close end