A library for drawing graphics on the console screen
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs Update docs Oct 12, 2018
examples Add specs Oct 15, 2018
spec Add specs Oct 15, 2018
src
.editorconfig Initial commit Oct 6, 2018
.gitignore Add docs Oct 6, 2018
.travis.yml Initial commit Oct 6, 2018
LICENSE Initial commit Oct 6, 2018
README.md Add specs Oct 15, 2018
shard.yml

README.md

Docs

lime

A library for drawing graphics on the console screen

Features

  • Drawing of
    • PNG images
    • text
    • rectangles
    • filled rectangles
    • circles
    • lines
  • Non-blocking key input
  • Management of the window and cursor

Installation

Add this to your application's shard.yml:

dependencies:
  lime:
    github: r00ster91/lime

Then run shards install.

Example

Three lights flashing repeatedly in order:

require "lime"

# Make drawables like Rectangle, Circle available
require "lime/drawables"
include Lime::Drawables

# Create the lights:
# they are red, green and blue rectangles with doubled lines
light1 = Rectangle.new(
  x: 2, y: 1,
  width: 5, height: 3,
  type: Double, color: :red
)
light2 = Rectangle.new(8, 1, 5, 3, Double, :green)
light3 = Rectangle.new(14, 1, 5, 3, Double, :blue)

# The light that is currently on
active = 1

loop do
  if active == 3
    active = 1
  else
    active += 1
  end

  case active
  when 1
    light1.color = :light_red
    light2.color = :green
    light3.color = :blue
  when 2
    light1.color = :red
    light2.color = :light_green
    light3.color = :blue
  when 3
    light1.color = :red
    light2.color = :green
    light3.color = :light_blue
  end

  # Insert the lights into the buffer:
  light1.draw
  light2.draw
  light3.draw

  # Draw the content of the buffer to the screen:
  Lime.draw
  # Clear the buffer so we have room for new stuff:
  Lime.clear

  # You can use `Lime.loop` instead of a normal loop to skip the above two steps

  sleep 0.5
end

In the top left corner we can see:

lights

See examples/ for more examples.

Contributing

  1. Fork it (https://github.com/r00ster91/lime/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes
  4. Make sure the specs compile (crystal spec -v)
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create a new Pull Request

Contributors