From 3ff304014b72f767ee72b85d162b2445bd8ba2c8 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 17 Jun 2019 21:41:50 -0400 Subject: [PATCH] README update for matrices --- README.md | 14 +++++++------- src/env.c | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 997e1c9..78cf152 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,17 @@ 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[X,Y\right]+3\left|\frac{A}{B}\right>} - {\left\{\frac{a_k+b_k}{5!}\right\}^n} -+ \sum_{k=1}^nk(-1)^k +\frac{x^7 \left[X,Y\right] + 3\left|\frac{A}{B}\right>} + {\left\{\frac{a_k+b_k}{k!}\right\}^5} ++ \int_a^b \frac{\left(b-t\right)^{n+1}}{n!} dt ++ \left(\begin{matrix} \frac{1}{2} & 5 \\ -1 & a+b \end{matrix}\right) ``` -![Sample image](https://framapic.org/MGABuOpMUDxn/duzY5eaLNVTj.png) +![Sample image](https://www.planet-casio.com/files/forums/TeX-13737.png) ## Features -* Build formulae from TeX syntax +* Build formulae from TeX syntax or using the structural API * Highly-customizable graphical and layout parameters * Drawing is based on a few user-provided primitives (point, line, text size, text) @@ -26,12 +27,11 @@ List of currently supported elements: * Grouping angle brackets, vertical lines, and dots (invisible) * Sums, products and integrals (`\sum`, `\prod` and `\int`) * Vectors (`\vec`) and limits (`\lim`) +* Matrices (`\begin{matrix} ... \end{matrix}`) Features that are partially implemented (and what is left to finish them): * Support for inline style and display style (expose a parameter) -* API functions to build TeX objects without a TeX formula (expose functions - which are currently in the parser) * Full fx-CG 50 support (suitable parenthesis styles) See the `TODO.md` file for more features to come. diff --git a/src/env.c b/src/env.c index dae0856..0603cae 100644 --- a/src/env.c +++ b/src/env.c @@ -171,6 +171,8 @@ static void matrix_layout(struct TeX_Env *env) } struct TeX_Flow *f = m->elements[i]; + if(!f) { col++; continue; } + TeX_flow_layout(f); /* Update the current row and column */ @@ -214,7 +216,7 @@ static void matrix_render(struct TeX_Env *env, int x, int y, int color) int cw = m->colwidth[col]; int rh = m->rowline[row] + m->rowdepth[row]; - TeX_flow_render(flow, + if(flow) TeX_flow_render(flow, x + dx + ((cw - flow->width) >> 1), y + dy + ((rh - flow->height) >> 1), color);