celestine

An SVG drawing library for Crystal

Celestine Crystal CI Documentation badge

Celestine Logo

A neat library and DSL for creating graphics using SVG

Installation

Add to shards.yml

dependencies:
  celestine:
    github: redcodefinal/celestine

SVG Stuff It Can Do

TODO

  • Filters :( gonna need to design a whole system just for those
  • Full SVG support for all elements and attributes

Usage

First, all drawing is done through Celestine.draw this returns a string SVG element, or works on an IO. You can easily embed this into webpages for dynamic server side drawing of assets.

Celestine.draw takes a block which takes a Celestine::Meta::Context, the basis of all DSL calls in Celestine.

Celestine.draw do |ctx|
end

You can create objects to be drawn with one of two methods.

Celestine.draw do |ctx|
  # use this context's DSL methods
  ctx.rectangle do |r|
    r.x = 10
    r.y = 100
    r.fill = "black"
    r # You must return the drawable item at the end of the DSL method.
  end

  # Create the object and add it manually
  r = Celestine::Rectangle.new
  r.x = 10
  r.y = 100
  r.fill = "black"
  ctx << r
end

A list of the Celestine types and their DSL methods

  • Celestine::Rectangle -> rectangle
  • Celestine::Circle -> circle
  • Celestine::Ellipse -> ellipse
  • Celestine::Path -> path
  • Celestine::Mask -> mask
  • Celestine::Text -> text
  • Celestine::Group -> group
  • Celestine::Image -> image
  • Celestine::Use -> use

Here's a quick and dirty intro to features. crash_course

Here are some more intricate examples. procedural_art

Real world examples made with Celestine. All of these are flat SVG files with no JS inside, using only functions built into Celestine.

Development

HMU via issues or make a pull request or something I don't know.

Contributing

  1. Fork it (https://github.com/redcodefinal/celestine/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Owner
github statistic
  • 14
  • 1
  • 1
  • 0
  • 2 days ago
  • March 29, 2020
License

MIT License

Links
Synced at

Fri, 27 Nov 2020 05:27:29 GMT