diff options
Diffstat (limited to 'libdimension/dimension')
-rw-r--r-- | libdimension/dimension/pattern.h | 55 | ||||
-rw-r--r-- | libdimension/dimension/patterns.h | 30 | ||||
-rw-r--r-- | libdimension/dimension/pigments.h | 13 | ||||
-rw-r--r-- | libdimension/dimension/texture.h | 4 |
4 files changed, 101 insertions, 1 deletions
diff --git a/libdimension/dimension/pattern.h b/libdimension/dimension/pattern.h new file mode 100644 index 0000000..6301372 --- /dev/null +++ b/libdimension/dimension/pattern.h @@ -0,0 +1,55 @@ +/************************************************************************* + * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> * + * * + * This file is part of The Dimension Library. * + * * + * The Dimension Library is free software; you can redistribute it and/ * + * or modify it under the terms of the GNU Lesser General Public License * + * as published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * The Dimension Library is distributed in the hope that it will be * + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this program. If not, see * + * <http://www.gnu.org/licenses/>. * + *************************************************************************/ + +/* + * Patterns + */ + +#ifndef DIMENSION_PATTERN_H +#define DIMENSION_PATTERN_H + +/* Forward-declare dmnsn_pattern */ +typedef struct dmnsn_pattern dmnsn_pattern; + +/* Pattern callback */ +typedef double dmnsn_pattern_fn(const dmnsn_pattern *pattern, dmnsn_vector v); + +/* Generic pattern */ +struct dmnsn_pattern { + /* Callbacks */ + dmnsn_pattern_fn *pattern_fn; + dmnsn_free_fn *free_fn; + + /* Transformation matrix */ + dmnsn_matrix trans, trans_inv; + + /* Generic pointer */ + void *ptr; +}; + +dmnsn_pattern *dmnsn_new_pattern(void); +void dmnsn_delete_pattern(dmnsn_pattern *pattern); + +void dmnsn_pattern_init(dmnsn_pattern *pattern); + +/* Invoke the pattern callback with the right transformation */ +double dmnsn_pattern_value(const dmnsn_pattern *pattern, dmnsn_vector v); + +#endif /* DIMENSION_PATTERN_H */ diff --git a/libdimension/dimension/patterns.h b/libdimension/dimension/patterns.h new file mode 100644 index 0000000..c6dc08a --- /dev/null +++ b/libdimension/dimension/patterns.h @@ -0,0 +1,30 @@ +/************************************************************************* + * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> * + * * + * This file is part of The Dimension Library. * + * * + * The Dimension Library is free software; you can redistribute it and/ * + * or modify it under the terms of the GNU Lesser General Public License * + * as published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * The Dimension Library is distributed in the hope that it will be * + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this program. If not, see * + * <http://www.gnu.org/licenses/>. * + *************************************************************************/ + +/* + * Custom patterns + */ + +#ifndef DIMENSION_PATTERNS_H +#define DIMENSION_PATTERNS_H + +dmnsn_pattern *dmnsn_new_checker_pattern(); + +#endif /* DIMENSION_PATTERNS_H */ diff --git a/libdimension/dimension/pigments.h b/libdimension/dimension/pigments.h index f985362..31c0598 100644 --- a/libdimension/dimension/pigments.h +++ b/libdimension/dimension/pigments.h @@ -30,4 +30,17 @@ dmnsn_pigment *dmnsn_new_solid_pigment(dmnsn_color color); /* An image map */ dmnsn_pigment *dmnsn_new_canvas_pigment(dmnsn_canvas *canvas); +/* Color maps */ +typedef dmnsn_array dmnsn_color_map; + +dmnsn_color_map *dmnsn_new_color_map(); +void dmnsn_delete_color_map(dmnsn_color_map *map); + +void dmnsn_add_color_map_entry(dmnsn_color_map *map, double n, dmnsn_color c); +dmnsn_color dmnsn_color_map_value(const dmnsn_color_map *map, double n); + +/* Color-mapped pigments */ +dmnsn_pigment *dmnsn_new_color_map_pigment(dmnsn_pattern *pattern, + dmnsn_color_map *map); + #endif /* DIMENSION_PIGMENTS_H */ diff --git a/libdimension/dimension/texture.h b/libdimension/dimension/texture.h index 3d37aa1..98e33b8 100644 --- a/libdimension/dimension/texture.h +++ b/libdimension/dimension/texture.h @@ -32,14 +32,16 @@ /* Forward-declare dmnsn_pigment */ typedef struct dmnsn_pigment dmnsn_pigment; -/* Pigment callback */ +/* Pigment callbacks */ typedef dmnsn_color dmnsn_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v); +typedef void dmnsn_pigment_init_fn(dmnsn_pigment *pigment); /* dmnsn_pigment definition */ struct dmnsn_pigment { /* Callbacks */ dmnsn_pigment_fn *pigment_fn; + dmnsn_pigment_init_fn *init_fn; dmnsn_free_fn *free_fn; /* Transformation matrix */ |