claude38715 / msgpack.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AAlib-Ruby brings graphics to the text terminal.  AAlib-Ruby provides both a
graphics context rendered as ascii-art and keyboard and mouse input.
AAlib-Ruby supports a number of text-only display drivers such as Curses,
SLang, and X11.

This is a DL based wrapper around the AA-lib C library.  C struct alignment
issues may cause problems on certain platforms when accessing variables of
some objects.

Author::  Patrick Mahoney (mailto:pat@polycrystal.org)
Copyright:: Copyright (c) 2007 Patrick Mahoney
License:: Distributes under the same terms as Ruby

== 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)

    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

About

License:Other


Languages

Language:Ruby 100.0%