diff --git a/README.md b/README.md index f93285a..42a043d 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,12 @@ This library is a customizable 2D math rendering tool for calculators. It can be used to render 2D formulae, either from an existing structure or TeX syntax. ```latex -\frac{x_7}{\left\{\frac{\frac{2}{3}}{27}\right\}^2} +\frac{x^7\left[X,Y\right]+3\left|\frac{A}{B}\right>} + {\left\{\frac{a_k+b_k}{5!}\right\}^n} ++ \sum_{k=1}^nk(-1)^k ``` -![Sample image](https://framapic.org/v4ODO95ftSAV/szXvX2amwuUN.png) +![Sample image](https://framapic.org/MGABuOpMUDxn/duzY5eaLNVTj.png) ## Features @@ -21,6 +23,8 @@ List of currently supported elements: * Fractions (`\frac`) * Subscripts and superscripts (`_` and `^`) * Grouping parentheses, brackets and braces (`\left` and `\right`) +* Grouping angle brackets, vertical lines, and dots (invisible) +* Summation symbols Features that are partially implemented (and what is left to finish them): diff --git a/src/classes.c b/src/classes.c index fd9af50..6c2a05e 100644 --- a/src/classes.c +++ b/src/classes.c @@ -118,6 +118,8 @@ void leftright_size(struct TeX_Node *node) if(node->subtype == '<' || node->subtype == '>') node->width = TEX_LEFTRIGHT_ANGLE_WIDTH; + if(node->subtype == '|') + node->width = 1; } void leftright_render(struct TeX_Node const * node, int x, int y, int color) @@ -183,6 +185,10 @@ void leftright_render(struct TeX_Node const * node, int x, int y, int color) TeX_line(x + w - 1, y + l, x, y, color); TeX_line(x + w - 1, y + l, x, y + h - 1, color); break; + + case '|': + TeX_line(x, y, x, y + h - 1, color); + break; } } diff --git a/src/platform/sdl2.c b/src/platform/sdl2.c index c521565..6c2df8d 100644 --- a/src/platform/sdl2.c +++ b/src/platform/sdl2.c @@ -117,7 +117,7 @@ static void init(void) if(SDL_Init(SDL_INIT_VIDEO) < 0) fail("failed to initialize SDL"); int c = SDL_WINDOWPOS_CENTERED; - w = SDL_CreateWindow("2D rendering", c, c, 256, 128, 0); + w = SDL_CreateWindow("2D rendering", c, c, 320, 240, 0); if(!w) fail("cannot create SDL window"); r = SDL_CreateRenderer(w, -1, SDL_RENDERER_ACCELERATED); @@ -161,9 +161,9 @@ static void fini(void) int main(void) { char const * formula = - "\\frac{x_7}{"//\\left+3\\left<\\frac{A}{B}\\right>}{" - "\\left\\{\\frac{\\frac{2}{3}}{27}\\right\\}^2" - "} + \\sum_{k=1}^nk"; + "\\frac{x^7\\left[X,Y\\right]+3\\left|\\frac{A}{B}\\right>}{" + "\\left\\{\\frac{a_k+b_k}{5!}\\right\\}^n" + "} + \\sum_{k=1}^nk(-1)^k"; struct TeX_Flow *flow = TeX_parse(formula); if(!flow) { puts("parsing error!"); return 1; }