recursivegrid

A small library for two-dimensional, recursive grids

recursivegrid

RecursiveGrid is a small library, written in Crystal. Main characteristics are:

  • two-dimensional grid
  • grids can contain grids, recursively
  • grid elements can be arbitrary classes
  • allow dynamical changes
  • an API that fits immediate mode GUI usage

... while abstracting away / hiding...

  • grid index counting on the user side
  • column and/or row spanning

In addition you can find a sample GUI wrapper (for ImGui) that also abstracts the following aspects:

  • pixel counting for both elements and optionally also (sub)grid frames
  • automatical resizing of elements

https://github.com/user-attachments/assets/80b9bc63-79d2-4ea2-be8b-4d9116c34e40

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      recursivegrid:
        github: wolfgang371/recursivegrid
    
  2. Run shards install

  3. Follow steps in setup.sh

  4. Run source ./setup.sh

Usage

Direct library usage

Simple example, taken from specs:

require "recursivegrid"

c = RecursiveGrid::Grid(Int32)
grid = c.new([[10, c.new([[20],[30]])]])
grid.size.should eq({2, 2})
grid.get_matrix.should eq([
    [10, 20],
    [10, 30]
])

Sample ImGui based GUI demo

As in src/imguidemo.cr, see above video.

Thanks

Thanks to...

Contributing

  1. Fork it (https://github.com/your-github-user/recursivegrid/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

Repository

recursivegrid

Owner
Statistic
  • 2
  • 0
  • 0
  • 0
  • 3
  • about 1 month ago
  • September 24, 2024
License

MIT License

Links
Synced at

Fri, 22 Nov 2024 14:33:59 GMT

Languages