summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdimension/pigment.c8
-rw-r--r--libdimension/solid_pigment.c16
2 files changed, 6 insertions, 18 deletions
diff --git a/libdimension/pigment.c b/libdimension/pigment.c
index 5522d71..7ed68e3 100644
--- a/libdimension/pigment.c
+++ b/libdimension/pigment.c
@@ -70,6 +70,10 @@ dmnsn_initialize_pigment(dmnsn_pigment *pigment)
dmnsn_color
dmnsn_evaluate_pigment(const dmnsn_pigment *pigment, dmnsn_vector v)
{
- dmnsn_vector v_trans = dmnsn_transform_vector(pigment->trans_inv, v);
- return pigment->pigment_fn(pigment, v_trans);
+ if (pigment->pigment_fn) {
+ dmnsn_vector v_trans = dmnsn_transform_vector(pigment->trans_inv, v);
+ return pigment->pigment_fn(pigment, v_trans);
+ } else {
+ return pigment->quick_color;
+ }
}
diff --git a/libdimension/solid_pigment.c b/libdimension/solid_pigment.c
index f53c5dc..c54ef63 100644
--- a/libdimension/solid_pigment.c
+++ b/libdimension/solid_pigment.c
@@ -26,27 +26,11 @@
#include "dimension.h"
#include <stdlib.h>
-/** Solid color pigment callback. */
-static dmnsn_color
-dmnsn_solid_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v)
-{
- dmnsn_color *color = pigment->ptr;
- return *color;
-}
-
/* Create a solid color */
dmnsn_pigment *
dmnsn_new_solid_pigment(dmnsn_color color)
{
dmnsn_pigment *pigment = dmnsn_new_pigment();
-
- dmnsn_color *solid = dmnsn_malloc(sizeof(dmnsn_color));
- *solid = color;
-
- pigment->pigment_fn = dmnsn_solid_pigment_fn;
- pigment->free_fn = dmnsn_free;
pigment->quick_color = color;
- pigment->ptr = solid;
-
return pigment;
}