summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d297097)
raw | patch | inline | side by side (parent: d297097)
author | jucablues <jucablues@users.sourceforge.net> | |
Thu, 26 Jul 2007 08:02:07 +0000 (08:02 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Thu, 26 Jul 2007 08:02:07 +0000 (08:02 +0000) |
*reading attributes and setting default values
same for some more attributes on convolve matrix filter
alphabetical ordering on Makefile_insert and on nr-filter.cpp #includes
same for some more attributes on convolve matrix filter
alphabetical ordering on Makefile_insert and on nr-filter.cpp #includes
12 files changed:
src/display/Makefile_insert | patch | blob | history | |
src/display/nr-filter-convolve-matrix.cpp | patch | blob | history | |
src/display/nr-filter-convolve-matrix.h | patch | blob | history | |
src/display/nr-filter-displacement-map.cpp | patch | blob | history | |
src/display/nr-filter-image.cpp | patch | blob | history | |
src/display/nr-filter-turbulence.cpp | [new file with mode: 0644] | patch | blob |
src/display/nr-filter-turbulence.h | [new file with mode: 0644] | patch | blob |
src/display/nr-filter.cpp | patch | blob | history | |
src/sp-feconvolvematrix.cpp | patch | blob | history | |
src/sp-feconvolvematrix.h | patch | blob | history | |
src/sp-feturbulence.cpp | patch | blob | history | |
src/sp-feturbulence.h | patch | blob | history |
index baeaaec620ad8b63b3be8b97dc3db0640aaac8b1..624733a42f2efbf3b9e7183f3186f541ec33dc82 100644 (file)
display/sp-ctrlquadr.h \
display/nr-filter.cpp \
display/nr-filter.h \
- display/nr-filter-primitive.cpp \
- display/nr-filter-primitive.h \
- display/nr-filter-gaussian.cpp \
- display/nr-filter-gaussian.h \
display/nr-filter-blend.cpp \
display/nr-filter-blend.h \
- display/nr-filter-diffuselighting.cpp \
- display/nr-filter-diffuselighting.h \
- display/nr-filter-offset.cpp \
- display/nr-filter-offset.h \
- display/nr-filter-specularlighting.cpp \
- display/nr-filter-specularlighting.h \
display/nr-filter-composite.h \
display/nr-filter-composite.cpp \
display/nr-filter-convolve-matrix.cpp \
display/nr-filter-convolve-matrix.h \
+ display/nr-filter-diffuselighting.cpp \
+ display/nr-filter-diffuselighting.h \
display/nr-filter-displacement-map.cpp \
display/nr-filter-displacement-map.h \
+ display/nr-filter-gaussian.cpp \
+ display/nr-filter-gaussian.h \
+ display/nr-filter-getalpha.cpp \
+ display/nr-filter-getalpha.h \
display/nr-filter-image.cpp \
display/nr-filter-image.h \
+ display/nr-filter-offset.cpp \
+ display/nr-filter-offset.h \
+ display/nr-filter-primitive.cpp \
+ display/nr-filter-primitive.h \
display/nr-filter-slot.cpp \
display/nr-filter-slot.h \
- display/nr-filter-getalpha.cpp \
- display/nr-filter-getalpha.h \
+ display/nr-filter-specularlighting.cpp \
+ display/nr-filter-specularlighting.h \
+ display/nr-filter-turbulence.cpp \
+ display/nr-filter-turbulence.h \
display/nr-filter-pixops.h \
display/nr-filter-types.h \
display/nr-filter-utils.h \
index 75a40df70d478e56cdb72e0c7f2ccdf6b0e5c396..f8a00cb4b734b07e0f706828ae0dadce355c5862 100644 (file)
namespace NR {
FilterConvolveMatrix::FilterConvolveMatrix()
+: bias(0),
+ edgeMode(0),
+ preserveAlpha(false)
{}
FilterPrimitive * FilterConvolveMatrix::create() {
kernelMatrix = km;
}
+void FilterConvolveMatrix::set_edgeMode(int mode){
+ edgeMode = mode;
+}
+
+void FilterConvolveMatrix::set_preserveAlpha(bool pa){
+ preserveAlpha = pa;
+}
+
void FilterConvolveMatrix::area_enlarge(NRRectL &area, Matrix const &trans)
{
//Seems to me that since this filter's operation is resolution dependent,
index e5b72a71fd1eff7c4d1c3a84cc1e66c74ac84035..f4a8230126fab961ea817ae062bb9fc1c95d2bbf 100644 (file)
void set_kernelMatrix(std::vector<gdouble>& km);
void set_bias(double b);
void set_divisor(double d);
+ void set_edgeMode(int mode);
+ void set_preserveAlpha(bool pa);
private:
std::vector<gdouble> kernelMatrix;
int targetX, targetY;
int orderX, orderY;
gdouble divisor, bias;
- int dx, dy; //kernelUnitLength
+ int dx, dy, kernelUnitLength;
+ int edgeMode;
+ bool preserveAlpha;
};
} /* namespace NR */
diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index 7d32ce2e0abdff7acf9958f0f1880006dad5a677..8d2e6dc3c2b657fd2c0082109412851597b2d91b 100644 (file)
x1 = out->area.x1;
y1 = out->area.y1;
width = x1 - x0;
-
+
for (x=x0 + scale/2; x < x1 - scale/2; x++){
for (y=y0 + scale/2; y < y1 - scale/2; y++){
/* SVG spec states that pixel values must be alpha-demultiplied before processing this filter operation.
index 62a8caf20dbd11c66e4bed103ab1757f6bfad208..b1a5b4d7aca4ca0a07954bcdee12bc524d89ede3 100644 (file)
FilterImage::FilterImage()
{
+ g_warning("FilterImage::render not implemented.");
/* Testing with hardcoded xlink:href :
image = Gdk::Pixbuf::create_from_file("/home/felipe/images/image1.jpg");
//TODO: handle errors
{}
int FilterImage::render(FilterSlot &slot, Matrix const &trans) {
+ return 0;
/* TODO: Implement this renderer method.
-Specification: http://www.w3.org/TR/SVG11/filters.html#feImage
+ Specification: http://www.w3.org/TR/SVG11/filters.html#feImage
- It would be good to findout how to reuse sp-image.cpp code
-
-After implementing it, add a reference to FilterImage::create
- on Filter::_create_constructor_table() (nr-filter.cpp file)
+ It would be good to findout how to reuse sp-image.cpp code
*/
/* int w,x,y;
diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * feTurbulence filter primitive renderer
+ *
+ * Authors:
+ * Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2007 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-turbulence.h"
+
+namespace NR {
+
+FilterTurbulence::FilterTurbulence()
+: XbaseFrequency(0),
+ YbaseFrequency(0),
+ numOctaves(1),
+ seed(0)
+{
+ g_warning("FilterTurbulence::render not implemented.");
+}
+
+FilterPrimitive * FilterTurbulence::create() {
+ return new FilterTurbulence();
+}
+
+FilterTurbulence::~FilterTurbulence()
+{}
+
+void FilterTurbulence::set_baseFrequency(int axis, double freq){
+ if (axis==0) XbaseFrequency=freq;
+ if (axis==1) YbaseFrequency=freq;
+}
+
+void FilterTurbulence::set_numOctaves(int num){
+ numOctaves=num;
+}
+
+void FilterTurbulence::set_seed(double s){
+ seed=s;
+}
+
+void FilterTurbulence::set_stitchTiles(bool st){
+ stitchTiles=st;
+}
+
+void FilterTurbulence::set_type(int t){
+ type=t;
+}
+
+
+int FilterTurbulence::render(FilterSlot &slot, Matrix const &trans) {
+/* TODO: Implement this renderer method.
+ Specification: http://www.w3.org/TR/SVG11/filters.html#feTurbulence
+
+*/
+
+/*debug: these are the available parameters
+ printf("XbaseFrequency = %f; ", XbaseFrequency);
+ printf("YbaseFrequency = %f; ", YbaseFrequency);
+ printf("numOctaves = %d;\n", numOctaves);
+ printf("seed = %f; ", seed);
+ printf("stitchTiles = %s; ", stitchTiles ? "stitch" : "noStitch");
+ printf("type = %s;\n\n", type==0 ? "FractalNoise" : "turbulence");
+*/
+
+//sample code: the following fills the whole area in semi-transparent red.
+ NRPixBlock *in = slot.get(_input);
+ NRPixBlock *out = new NRPixBlock;
+ int x,y;
+ int x0 = in->area.x0, y0 = in->area.y0;
+ int x1 = in->area.x1, y1 = in->area.y1;
+ int w = x1 - x0;
+ nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true);
+
+ unsigned char *out_data = NR_PIXBLOCK_PX(out);
+ for (x=x0; x < x1; x++){
+ for (y=y0; y < y1; y++){
+ out_data[4*((x - x0)+w*(y - y0)) + 0] = 255;
+ out_data[4*((x - x0)+w*(y - y0)) + 1] = 0;
+ out_data[4*((x - x0)+w*(y - y0)) + 2] = 0;
+ out_data[4*((x - x0)+w*(y - y0)) + 3] = 128;
+ }
+ }
+
+ out->empty = FALSE;
+ slot.set(_output, out);
+ return 0;
+}
+
+} /* namespace NR */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __NR_FILTER_TURBULENCE_H__
+#define __NR_FILTER_TURBULENCE_H__
+
+/*
+ * feTurbulence filter primitive renderer
+ *
+ * Authors:
+ * Felipe Sanches <felipe.sanches@gmail.com>
+ * Niko Kiirala <niko@kiirala.com>
+ *
+ * Copyright (C) 2007 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-primitive.h"
+#include "display/nr-filter-slot.h"
+
+namespace NR {
+
+class FilterTurbulence : public FilterPrimitive {
+public:
+ FilterTurbulence();
+ static FilterPrimitive *create();
+ virtual ~FilterTurbulence();
+
+ virtual int render(FilterSlot &slot, Matrix const &trans);
+ virtual void set_baseFrequency(int axis, double freq);
+ virtual void set_numOctaves(int num);
+ virtual void set_seed(double s);
+ virtual void set_stitchTiles(bool st);
+ virtual void set_type(int t);
+private:
+ double XbaseFrequency, YbaseFrequency;
+ int numOctaves;
+ double seed;
+ bool stitchTiles;
+ int type;
+};
+
+} /* namespace NR */
+
+#endif /* __NR_FILTER_TURBULENCE_H__ */
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index eb6a48e6c97dc606bcf5b39ef14c3c1fa6720dd5..f09573eb4694e5d4eb7c17b365d5596c692ef26e 100644 (file)
#include "display/pixblock-scaler.h"
#include "display/pixblock-transform.h"
-#include "display/nr-filter-displacement-map.h"
-#include "display/nr-filter-gaussian.h"
-#include "display/nr-filter-convolve-matrix.h"
#include "display/nr-filter-blend.h"
-#include "display/nr-filter-offset.h"
#include "display/nr-filter-composite.h"
+#include "display/nr-filter-convolve-matrix.h"
#include "display/nr-filter-diffuselighting.h"
-#include "display/nr-filter-specularlighting.h"
+#include "display/nr-filter-displacement-map.h"
+#include "display/nr-filter-gaussian.h"
#include "display/nr-filter-image.h"
+#include "display/nr-filter-offset.h"
+#include "display/nr-filter-specularlighting.h"
+#include "display/nr-filter-turbulence.h"
#include "display/nr-arena-item.h"
#include "libnr/nr-pixblock.h"
static bool created = false;
if(created) return;
- /* Filter effects not yet implemented are set to NULL */
+/* Some filter classes are not implemented yet.
+ Filters with constructors appearing in this table are not necessarilly already implemented.
+ Some of them still have only boilerplate-code.*/
_constructor[NR_FILTER_BLEND] = &FilterBlend::create;
_constructor[NR_FILTER_COLORMATRIX] = NULL;
_constructor[NR_FILTER_COMPONENTTRANSFER] = NULL;
_constructor[NR_FILTER_DISPLACEMENTMAP] = &FilterDisplacementMap::create;
_constructor[NR_FILTER_FLOOD] = NULL;
_constructor[NR_FILTER_GAUSSIANBLUR] = &FilterGaussian::create;
- _constructor[NR_FILTER_IMAGE] = NULL;
+ _constructor[NR_FILTER_IMAGE] = &FilterImage::create;
_constructor[NR_FILTER_MERGE] = NULL;
_constructor[NR_FILTER_MORPHOLOGY] = NULL;
_constructor[NR_FILTER_OFFSET] = &FilterOffset::create;
_constructor[NR_FILTER_SPECULARLIGHTING] = &FilterSpecularLighting::create;
_constructor[NR_FILTER_TILE] = NULL;
- _constructor[NR_FILTER_TURBULENCE] = NULL;
+ _constructor[NR_FILTER_TURBULENCE] = &FilterTurbulence::create;
created = true;
}
index 4191cceecfae0a2cf3ce0c8b49d1e37cd827f07e..059475e5fc40ae8487e28c75d6ada2bd95cf5a76 100644 (file)
return ret;
}
+static int sp_feConvolveMatrix_read_edgeMode(gchar const *value){
+ if (!value) return 0; //duplicate is default
+ switch(value[0]){
+ case 'd':
+ if (strncmp(value, "duplicate", 9) == 0) return 0;
+ break;
+ case 'w':
+ if (strncmp(value, "wrap", 4) == 0) return 1;
+ break;
+ case 'n':
+ if (strncmp(value, "none", 4) == 0) return 2;
+ break;
+ }
+ return 0; //duplicate is default
+}
+
+
+static bool sp_feConvolveMatrix_read_bool(gchar const *value){
+ if (!value) return false; //false is default
+ switch(value[0]){
+ case 't':
+ if (strncmp(value, "true", 4) == 0) return true;
+ break;
+ case 'f':
+ if (strncmp(value, "false", 5) == 0) return false;
+ break;
+ }
+ return false; //false is default
+}
+
/**
* Sets a specific value in the SPFeConvolveMatrix.
*/
@@ -152,7 +182,10 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value)
{
SPFeConvolveMatrix *feConvolveMatrix = SP_FECONVOLVEMATRIX(object);
(void)feConvolveMatrix;
-
+ double read_num;
+ int read_int;
+ bool read_bool;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_ORDER:
@@ -164,32 +197,51 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value)
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_DIVISOR:
- feConvolveMatrix->divisor = sp_feConvolveMatrix_read_number(value);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ read_num = sp_feConvolveMatrix_read_number(value);
+ if (read_num != feConvolveMatrix->divisor){
+ feConvolveMatrix->divisor = read_num;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
case SP_ATTR_BIAS:
- feConvolveMatrix->bias = sp_feConvolveMatrix_read_number(value);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ read_num = sp_feConvolveMatrix_read_number(value);
+ if (read_num != feConvolveMatrix->bias){
+ feConvolveMatrix->bias = read_num;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
case SP_ATTR_TARGETX:
- feConvolveMatrix->targetX = (int) sp_feConvolveMatrix_read_number(value);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ read_int = (int) sp_feConvolveMatrix_read_number(value);
+ if (read_int != feConvolveMatrix->targetX){
+ feConvolveMatrix->targetX = read_int;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
case SP_ATTR_TARGETY:
- feConvolveMatrix->targetY = (int) sp_feConvolveMatrix_read_number(value);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ read_int = (int) sp_feConvolveMatrix_read_number(value);
+ if (read_int != feConvolveMatrix->targetY){
+ feConvolveMatrix->targetY = read_int;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
case SP_ATTR_EDGEMODE:
- //TODO
+ read_int = (int) sp_feConvolveMatrix_read_edgeMode(value);
+ if (read_int != feConvolveMatrix->edgeMode){
+ feConvolveMatrix->edgeMode = read_int;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
case SP_ATTR_KERNELUNITLENGTH:
feConvolveMatrix->kernelUnitLength.set(value);
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_PRESERVEALPHA:
- //TODO
+ read_bool = sp_feConvolveMatrix_read_bool(value);
+ if (read_bool != feConvolveMatrix->preserveAlpha){
+ feConvolveMatrix->preserveAlpha = read_bool;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
-
default:
if (((SPObjectClass *) feConvolveMatrix_parent_class)->set)
((SPObjectClass *) feConvolveMatrix_parent_class)->set(object, key, value);
index 53ed8b741e822c65e1439866ab8640f9bc16f7bb..0cb4abc67e5bf0782bb162ada9e82d67842fd753 100644 (file)
std::vector<gdouble> kernelMatrix;
double divisor, bias;
int targetX, targetY;
- unsigned short edgeMode;
+ int edgeMode;
NumberOptNumber kernelUnitLength;
bool preserveAlpha;
};
index f1f99a61355a5e8140ee96984a5d0e5ee6256f21..1387789842c6683bf6f4c2c249bf2b172788ac8d 100644 (file)
--- a/src/sp-feturbulence.cpp
+++ b/src/sp-feturbulence.cpp
*/
/*
* Authors:
+ * Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
* hugo Rodrigues <haa.rodrigues@gmail.com>
*
+ * Copyright (C) 2007 Felipe Sanches
* Copyright (C) 2006 Hugo Rodrigues
*
* Released under GNU GPL, read the file 'COPYING' for more information
#include "svg/svg.h"
#include "sp-feturbulence.h"
#include "xml/repr.h"
+#include <string.h>
+#include "display/nr-filter.h"
+#include "display/nr-filter-turbulence.h"
/* FeTurbulence base class */
static void sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value);
static void sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags);
static Inkscape::XML::Node *sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static void sp_feTurbulence_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter);
static SPFilterPrimitiveClass *feTurbulence_parent_class;
sp_feTurbulence_class_init(SPFeTurbulenceClass *klass)
{
SPObjectClass *sp_object_class = (SPObjectClass *)klass;
+ SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass;
feTurbulence_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass);
sp_object_class->write = sp_feTurbulence_write;
sp_object_class->set = sp_feTurbulence_set;
sp_object_class->update = sp_feTurbulence_update;
+
+ sp_primitive_class->build_renderer = sp_feTurbulence_build_renderer;
}
static void
}
/*LOAD ATTRIBUTES FROM REPR HERE*/
+ sp_object_read_attr(object, "baseFrequency");
+ sp_object_read_attr(object, "numOctaves");
+ sp_object_read_attr(object, "seed");
+ sp_object_read_attr(object, "stitchTiles");
+ sp_object_read_attr(object, "type");
}
/**
((SPObjectClass *) feTurbulence_parent_class)->release(object);
}
+static double
+sp_feTurbulence_read_number(gchar const *value) {
+ if (!value) return 0;
+ char *end;
+ double ret = g_ascii_strtod(value, &end);
+ if (*end) {
+ g_warning("Unable to convert \"%s\" to number", value);
+ // We could leave this out, too. If strtod can't convert
+ // anything, it will return zero.
+ ret = 0;
+ }
+ return ret;
+}
+
+static bool sp_feTurbulence_read_stitchTiles(gchar const *value){
+ if (!value) return false; // 'noStitch' is default
+ switch(value[0]){
+ case 's':
+ if (strncmp(value, "stitch", 6) == 0) return true;
+ break;
+ case 'n':
+ if (strncmp(value, "noStitch", 8) == 0) return false;
+ break;
+ }
+ return false; // 'noStitch' is default
+}
+
+static int sp_feTurbulence_read_type(gchar const *value){
+ if (!value) return 1; // 'turbulence' is default
+ switch(value[0]){
+ case 'f':
+ if (strncmp(value, "fractalNoise", 12) == 0) return 0;
+ break;
+ case 't':
+ if (strncmp(value, "turbulence", 10) == 0) return 1;
+ break;
+ }
+ return 1; // 'turbulence' is default
+}
+
/**
* Sets a specific value in the SPFeTurbulence.
*/
SPFeTurbulence *feTurbulence = SP_FETURBULENCE(object);
(void)feTurbulence;
+ int read_int;
+ double read_num;
+ bool read_bool;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
+
+ case SP_ATTR_BASEFREQUENCY:
+ feTurbulence->baseFrequency.set(value);
+ //From SVG spec: If two <number>s are provided, the first number represents a base frequency in the X direction and the second value represents a base frequency in the Y direction. If one number is provided, then that value is used for both X and Y.
+ if (feTurbulence->baseFrequency.getOptNumber() == -1) // -1 means "not set"
+ feTurbulence->baseFrequency.setOptNumber(feTurbulence->baseFrequency.getNumber());
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
+ case SP_ATTR_NUMOCTAVES:
+ read_int = (int) sp_feTurbulence_read_number(value);
+ if (read_int != feTurbulence->numOctaves){
+ feTurbulence->numOctaves = read_int;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+ case SP_ATTR_SEED:
+ read_num = sp_feTurbulence_read_number(value);
+ if (read_num != feTurbulence->seed){
+ feTurbulence->seed = read_num;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+ case SP_ATTR_STITCHTILES:
+ read_bool = sp_feTurbulence_read_stitchTiles(value);
+ if (read_bool != feTurbulence->stitchTiles){
+ feTurbulence->stitchTiles = read_bool;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+ case SP_ATTR_TYPE:
+ read_int = sp_feTurbulence_read_type(value);
+ if (read_int != feTurbulence->type){
+ feTurbulence->type = read_int;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
default:
if (((SPObjectClass *) feTurbulence_parent_class)->set)
((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value);
@@ -161,6 +255,26 @@ sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
return repr;
}
+static void sp_feTurbulence_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) {
+ g_assert(primitive != NULL);
+ g_assert(filter != NULL);
+
+ SPFeTurbulence *sp_turbulence = SP_FETURBULENCE(primitive);
+
+ int primitive_n = filter->add_primitive(NR::NR_FILTER_TURBULENCE);
+ NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
+ NR::FilterTurbulence *nr_turbulence = dynamic_cast<NR::FilterTurbulence*>(nr_primitive);
+ g_assert(nr_turbulence != NULL);
+
+ sp_filter_primitive_renderer_common(primitive, nr_primitive);
+
+ nr_turbulence->set_baseFrequency(0, sp_turbulence->baseFrequency.getNumber());
+ nr_turbulence->set_baseFrequency(1, sp_turbulence->baseFrequency.getOptNumber());
+ nr_turbulence->set_numOctaves(sp_turbulence->numOctaves);
+ nr_turbulence->set_seed(sp_turbulence->seed);
+ nr_turbulence->set_stitchTiles(sp_turbulence->stitchTiles);
+ nr_turbulence->set_type(sp_turbulence->type);
+}
/*
Local Variables:
diff --git a/src/sp-feturbulence.h b/src/sp-feturbulence.h
index bf9ed2572607a1addd057bc8d0b5c01e2b47a490..7f9adae130ad91c086e7023e3e7a26bf4184c8a4 100644 (file)
--- a/src/sp-feturbulence.h
+++ b/src/sp-feturbulence.h
*/
/*
* Authors:
+ * Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
* Hugo Rodrigues <haa.rodrigues@gmail.com>
*
* Copyright (C) 2006 Hugo Rodrigues
#include "sp-filter.h"
#include "sp-feturbulence-fns.h"
+#include "number-opt-number.h"
/* FeTurbulence base class */
class SPFeTurbulenceClass;
struct SPFeTurbulence : public SPFilterPrimitive {
/** TURBULENCE ATTRIBUTES HERE */
-
+ NumberOptNumber baseFrequency;
+ int numOctaves;
+ double seed;
+ bool stitchTiles;
+ int type;
};
struct SPFeTurbulenceClass {