summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2008-08-22 20:52:13 +0200
committerGuillaume Seguin <guillaume@segu.in>2008-08-22 20:52:13 +0200
commite66726bc49786a1c12926250f1901786799080e6 (patch)
treeba4f87a4608c924c96e0402a833f1a174aba1f7b
parent213e415c7879d9f1b9d2a3a285e79b8974d12591 (diff)
downloadgmathlib-e66726bc49786a1c12926250f1901786799080e6.tar.gz
gmathlib-e66726bc49786a1c12926250f1901786799080e6.tar.bz2
* Add renderers for intersection and union symbols and update doc
-rw-r--r--doc/templates/Symbols18
-rw-r--r--gmathcairo/gmathcairo_renderers.c39
-rw-r--r--gmathlib/gmathtemplates.c4
3 files changed, 50 insertions, 11 deletions
diff --git a/doc/templates/Symbols b/doc/templates/Symbols
index a6f2876..c0ef32a 100644
--- a/doc/templates/Symbols
+++ b/doc/templates/Symbols
@@ -151,18 +151,20 @@ Template description template:
- union:
* An union symbol
* Value: no
- * Children: 3:
- o 0: union parameter
- o 1: left item
- o 2: right item
+ * Children: 4:
+ o 0: bottom parameter
+ o 1: top parameter
+ o 2: left item
+ o 3: right item
* Example: A ∪ B
- intersection:
* An intersection symbol
* Value: no
- * Children: 3:
- o 0: intersection parameter
- o 1: left item
- o 2: right item
+ * Children: 4:
+ o 0: bottom parameter
+ o 1: top parameter
+ o 2: left item
+ o 3: right item
* Example: A ∩ B
- concat:
* A seamless concatenation symbol
diff --git a/gmathcairo/gmathcairo_renderers.c b/gmathcairo/gmathcairo_renderers.c
index 2e5b403..cbc1cc3 100644
--- a/gmathcairo/gmathcairo_renderers.c
+++ b/gmathcairo/gmathcairo_renderers.c
@@ -1181,6 +1181,39 @@ render_integral (GMathCairoContext *ccontext, GMathSymbol *symbol, float size)
return boxed;
}
+/* Render an union symbol */
+GMathBoxed*
+render_union (GMathCairoContext *ccontext, GMathSymbol *symbol, float size)
+{
+ if (!symbol)
+ return NULL;
+
+ return gmathcairo_render_cross_symbol (ccontext, NULL, draw_union,
+ symbol->children[2],
+ symbol->children[3],
+ symbol->children[1],
+ symbol->children[0],
+ true, true, true, true,
+ size, symbol);
+}
+
+/* Render an intersection symbol */
+GMathBoxed*
+render_intersection (GMathCairoContext *ccontext, GMathSymbol *symbol,
+ float size)
+{
+ if (!symbol)
+ return NULL;
+
+ return gmathcairo_render_cross_symbol (ccontext, NULL, draw_intersection,
+ symbol->children[2],
+ symbol->children[3],
+ symbol->children[1],
+ symbol->children[0],
+ true, true, true, true,
+ size, symbol);
+}
+
/* Register renderers */
void
gmathcairo_register_renderers (GMathCairoContext *ccontext)
@@ -1204,7 +1237,11 @@ gmathcairo_register_renderers (GMathCairoContext *ccontext)
gmathcairocontext_register_renderer (ccontext, "super", render_super);
gmathcairocontext_register_renderer (ccontext, "sum", render_sum);
gmathcairocontext_register_renderer (ccontext, "product", render_product);
- gmathcairocontext_register_renderer (ccontext, "integral", render_integral);
+ gmathcairocontext_register_renderer (ccontext, "integral",
+ render_integral);
+ gmathcairocontext_register_renderer (ccontext, "union", render_union);
+ gmathcairocontext_register_renderer (ccontext, "intersection",
+ render_intersection);
/* Special chars */
gmathcairocontext_register_renderer (ccontext, "alpha", render_char);
diff --git a/gmathlib/gmathtemplates.c b/gmathlib/gmathtemplates.c
index a2ddcac..18d5805 100644
--- a/gmathlib/gmathtemplates.c
+++ b/gmathlib/gmathtemplates.c
@@ -51,8 +51,8 @@ gmath_register_templates (GMathContext *context)
gmathcontext_register_template (context, "array", false, 1); /* placeholder */
gmathcontext_register_template (context, "super", false, 2); /* a² */
gmathcontext_register_template (context, "sub", false, 2); /* a2 <- sub */
- gmathcontext_register_template (context, "union", false, 3); /* A ∪ B */
- gmathcontext_register_template (context, "intersection", false, 3); /* A ∩ B */
+ gmathcontext_register_template (context, "union", false, 4); /* A ∪ B */
+ gmathcontext_register_template (context, "intersection", false, 4); /* A ∩ B */
gmathcontext_register_template (context, "concat", false, 2); /* 2a */
/* Chars */