package

github.com/jmakino/gr-crystal

master / published Oct 9, 2022 / repository

Crystal API for GR framework

gr-crystal

Crystal binding for GR framework

A (still incomplete) interface to GR framework from Crystal

Installation

  1. You need to install GR in the standard way and set the enviromental variable GRDIR point to the installed directory.

  2. Add the dependency to your shard.yml:

    dependencies:
      grlib:
        github: jmakino/gr-crystal
  3. Run shards install

Getting started

At your project directory (where you ran shards install), try

crystal lib/grlib/examples/grsample.cr

should show a simple plot.

  • GRDIR env variable should point to the directory where you placed gr files. In particular, lib and fonts directories should be there
  • GKS_WSTYPE env variable should be set. For X11, its value should be "x11".

Usage

Essentially the same as that for C binging. Difference:

  • All size+pointer arguments to C array are replaced by Crystal arrays.

  • C char* is replaced by Crysral Sring

Example of API

void gr_polyline(int, double *, double *)

is called as

GR.polyline(Array(Float64), Array(Float64))

Examples

polyline plot

contour plot

3d contour plot

3d animation

log-log plot

semilog plot

Todo

All source and documents should be generated automatically...

API