Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aalib-ruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aalib-ruby

  • 0.7.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 25 Jul 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc