TilakChad / Morph

Simple graph plotter for easy bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Morph

A simple graph plotter API that is readily callable from C and is easy to interface with other languages.

A simple graph plotter that can plot real valued function (discontinuous plotting is restricted to one function for now).

Morph stands for Morphism in a sense that graph plotting is basically mapping points obtained from function to screen pixels:D.

Build

open(Morph.sln).then(Ctrl+F5)

Linux Build

Just provide required glfw's *.c files to cc and some -I* and -L* things and it compiles. If not clear, wait for build.sh or cmakelists.txt file.

Demo -> Func Plot

#define _CRT_SECURE_NO_WARNINGS

#include "./Morph.h"
#include <math.h>

double xcube(double x)
{
    return x * x * x;
}

int main()
{
    MorphPlotDevice device = MorphCreateDevice();
    // Add Gaussian * 4 func here 
    MorphPlotFunc(&device, xcube, 0.0f, 0.0f, 1.0f,-10.0f,10.0f, "x^3",0.0f);
    MorphPlotFunc(&device, sqrt, 1.0f, 0.0f, 1.0f,0.0f,200.0f, "sqrt",0.1f);
    MorphShow(&device);
    return 0;
}

Output

Demo -> List Plot

#include "./Morph.h"

int main()
{
   MorphPlotDevice device = MorphCreateDevice();
   
   float x[] = {1, 3, 4, 6, 7};
   float y[] = {3, -4, 3, -2, 0};
   MorphPlotList(&device, x, y, 5, 0.3f, 0.2f, 0.9f, "MagicFunc");
  
   MorphShow(&device);
   return 0;
}

Output

Implicit functions

Interactive Demo

Taking screenshot

Press Ctrl-S to save screenshot
Output image will be saved in the working directory : screenshot.bmp

TODO

  • Plotting of Vector Field
  • Customizations

About

Simple graph plotter for easy bindings


Languages

Language:C 92.2%Language:Objective-C 7.2%Language:CMake 0.5%Language:GLSL 0.1%Language:Shell 0.0%Language:Batchfile 0.0%