summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-22 12:01:14 -0500
committerTavian Barnes <tavianator@gmail.com>2010-11-22 12:01:14 -0500
commitf77a53bf817920bfa94c2a6d83d5e7066b157134 (patch)
treef18c17148198a16a30606a61e52a465cbaca7285 /dimension
parent8054e510b83702b931f3b81bb1e1385f9a7ecb80 (diff)
downloaddimension-f77a53bf817920bfa94c2a6d83d5e7066b157134.tar.xz
Generisise map implementation.
Diffstat (limited to 'dimension')
-rw-r--r--dimension/realize.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/dimension/realize.c b/dimension/realize.c
index 2f74ce0..ddccf89 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -480,29 +480,29 @@ dmnsn_realize_pattern(dmnsn_astnode astnode)
return pattern;
}
-static dmnsn_color_map *
+static dmnsn_map *
dmnsn_realize_color_list(dmnsn_astnode astnode)
{
dmnsn_assert(astnode.type == DMNSN_AST_COLOR_LIST, "Expected a color list.");
- dmnsn_color_map *color_map = dmnsn_new_color_map();
+ dmnsn_map *color_map = dmnsn_new_color_map();
double n = 0.0, i = 1.0/(dmnsn_array_size(astnode.children) - 1);
DMNSN_ARRAY_FOREACH (dmnsn_astnode *, entry, astnode.children) {
dmnsn_color color = dmnsn_realize_color(*entry);
- dmnsn_add_color_map_entry(color_map, n, color);
+ dmnsn_add_map_entry(color_map, n, &color);
n += i;
}
return color_map;
}
-static dmnsn_color_map *
+static dmnsn_map *
dmnsn_realize_color_map(dmnsn_astnode astnode)
{
dmnsn_assert(astnode.type == DMNSN_AST_COLOR_MAP, "Expected a color_map.");
- dmnsn_color_map *color_map = dmnsn_new_color_map();
+ dmnsn_map *color_map = dmnsn_new_color_map();
DMNSN_ARRAY_FOREACH (dmnsn_astnode *, entry, astnode.children) {
dmnsn_assert(entry->type == DMNSN_AST_COLOR_MAP_ENTRY,
@@ -515,7 +515,7 @@ dmnsn_realize_color_map(dmnsn_astnode astnode)
double n = dmnsn_realize_float(n_node);
dmnsn_color color = dmnsn_realize_color(color_node);
- dmnsn_add_color_map_entry(color_map, n, color);
+ dmnsn_add_map_entry(color_map, n, &color);
}
return color_map;
@@ -528,7 +528,7 @@ dmnsn_realize_pattern_pigment(dmnsn_astnode type, dmnsn_astnode modifiers)
"Expected pigment modifiers");
dmnsn_pattern *pattern = dmnsn_realize_pattern(type);
- dmnsn_color_map *color_map = NULL;
+ dmnsn_map *color_map = NULL;
/* Set up the color_map */
DMNSN_ARRAY_FOREACH_REVERSE (dmnsn_astnode *, modifier, modifiers.children) {
@@ -558,18 +558,18 @@ dmnsn_realize_pattern_pigment(dmnsn_astnode type, dmnsn_astnode modifiers)
/* Default checker pattern is blue and green */
if (!color_map)
color_map = dmnsn_new_color_map();
- if (dmnsn_array_size(color_map) < 1)
- dmnsn_add_color_map_entry(color_map, 0.0, dmnsn_blue);
- if (dmnsn_array_size(color_map) < 2)
- dmnsn_add_color_map_entry(color_map, 1.0, dmnsn_green);
+ if (dmnsn_map_size(color_map) < 1)
+ dmnsn_add_map_entry(color_map, 0.0, &dmnsn_blue);
+ if (dmnsn_map_size(color_map) < 2)
+ dmnsn_add_map_entry(color_map, 1.0, &dmnsn_green);
break;
default:
/* Default map is grayscale */
if (!color_map) {
color_map = dmnsn_new_color_map();
- dmnsn_add_color_map_entry(color_map, 0.0, dmnsn_black);
- dmnsn_add_color_map_entry(color_map, 1.0, dmnsn_white);
+ dmnsn_add_map_entry(color_map, 0.0, &dmnsn_black);
+ dmnsn_add_map_entry(color_map, 1.0, &dmnsn_white);
}
break;
}