Chitra - 2D graphics library

Chitra

Crystal language library to generate 2D graphics.

Name

Chitra is a Kannada(Karnataka, India) word which means Drawing.

Install

Install Cairo

Ubuntu

sudo apt install libcairo2 libcairo2-dev libpango1.0-dev

Fedora

sudo yum install cairo-devel pango-devel

Mac

brew install cairo pango

Add this to your application's shard.yml:

dependencies:
  chitra:
    github: aravindavk/chitra

Example (Global context)

require "chitra"

size 200, 10
(0..100).each do |x|
    fill x/100, 0, 0
    rect x*2, 0, 2, height
end
save "all_red.png"

Above example produces nice gradient like below.

All Red

Example (Without using global context)

require "chitra/context"

ctx = Chitra.new 200, 10
(0..100).each do |x|
    ctx.fill x/100, 0, 0
    ctx.rect x*2, 0, 2, ctx.height
end
ctx.save "all_red.png"

Documentation

Read the docs here.

Thanks

Contributing

Contributors