Giter Site home page Giter Site logo

wooster0 / lime Goto Github PK

View Code? Open in Web Editor NEW
32.0 5.0 1.0 125 KB

A library for drawing graphics on the console screen

Home Page: https://r00ster91.github.io/lime/

License: MIT License

Crystal 100.00%
lime terminal console graphics graphics-library crystal drawing draw-graphics cursor mouse

lime's Introduction

Wool supersedes this library. It can more or less do everything this library can.


Docs

lime

A library for drawing graphics on the console screen

Features

  • Drawing of
    • text
    • lines
    • rectangles
    • filled rectangles
    • circles
    • PNG images
  • Management of the window
  • Controlling of the console cursor
  • Keyboard and mouse pointer input

Installation

Add the dependency to your shard.yml:

dependencies:
  lime:
    github: r00ster91/lime

Then run shards install

Example

Three lights flashing repeatedly in order:

require "lime"

# 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
light = 1

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

  case light
  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 (not the screen) so we have room for the next frame:
  Lime.clear

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

  # A short delay:
  sleep 0.5
end

In the top left corner we can see:

lights

See examples for more examples.

For technical information about lime, see src/README.md.

Contributing

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

Contributors

lime's People

Contributors

wooster0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

selenecosmia

lime's Issues

Draw a character at a specific position

First off, cool shard, I've been looking for something similar so this should save me time, thanks!

On to the question, I might be missing something but I don't see if i could draw a character to a certain position (e.g. "a" to row 5, col 7). Is this possible?

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.