Giter Site home page Giter Site logo

jsoncanvas's Introduction

jsonCanvas

jsonCanvas is an implementation of the JSONCanvas Spec in C.

This library does ONLY provide the ability to create JSONCanvas files, and not to render them!

Usage

This library is in the style of the great stb-headers which means you just have to include the header file in your project and you're done.

NOTE: By default, jsoncanvas.h acts as a normal header file. When defining the JSONCANVAS_IMPLEMENTATION macro in ONLY ONE source file, it pastes the implementation (what in this case would be "jsoncanvas.c") into the C-File it is included in. INCLUDING jsoncanvas.h WITH THE MACRO IN MORE THAN ONE FILE LEADS TO ODR-VIOLATIONS

#define JSONCANVAS_IMPLEMENTATION // only define in *one* file
#include "jsoncanvas.h" // include everywhere you want
...

See example.c for an example.

Api

bool jcanvas_init(jcanvas* result);
jcanvas_node* jcanvas_text_node_s(jcanvas* c, str id, str content);
jcanvas_node* jcanvas_text_node(jcanvas* c, char* id, char* content);
jcanvas_node* jcanvas_file_node_s(jcanvas* c, str id, str content);
jcanvas_node* jcanvas_file_node(jcanvas* c, char* id, char* content);
jcanvas_node* jcanvas_link_node_s(jcanvas* c, str id, str link);
jcanvas_node* jcanvas_link_node(jcanvas* c, char* id, char* link);
jcanvas_node* jcanvas_group_node_s(jcanvas* c, str id);
jcanvas_node* jcanvas_group_node(jcanvas* c, char* id);
void jcanvas_set_label_s(jcanvas_node* node, str label);
void jcanvas_set_label(jcanvas_node* node, char* label);
void jcanvas_set_background_image_s(jcanvas_node* node, str path);
void jcanvas_set_background_image(jcanvas_node* node, char* path);
void jcanvas_set_background_style(jcanvas_node* node, jcanvas_background_style style);
jcanvas_edge* jcanvas_connect(jcanvas* c, jcanvas_node* a, jcanvas_node* b);
void jcanvas_pos_node(jcanvas_node* node, int64_t x, int64_t y, int64_t width, int64_t height);
str jcanvas_generate(jcanvas* c);
void jcanvas_destroy(jcanvas* c);

Making changes

For comfort purposes, the actual development happens in src/_jsoncanvas.c and src/_jsoncanvas.h. Change those files for changes and generate the single-header file by running the generate_header.py script.
The default allocator can be changed by defining the ALLOCATE and FREE macros.

jsoncanvas's People

Contributors

ossldossl avatar

Stargazers

wuxiec avatar  avatar Kowsheek avatar Gregory Tereshko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.