summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJasper van de Gronde <jasper.vandegronde@gmail.com>2015-01-06 19:52:44 +0000
committerJaspervdg <th.v.d.gronde@hccnet.nl>2015-01-06 19:52:44 +0000
commit397d39e20cc0aa3b50f473b57a79603dbc2f65f2 (patch)
tree3e056a1ef5885f9d14b05df037758524f6245139 /src
parentAdd getDocumentScale() to return "real-world" to "user-unit" scale factor. (diff)
downloadinkscape-397d39e20cc0aa3b50f473b57a79603dbc2f65f2.tar.gz
inkscape-397d39e20cc0aa3b50f473b57a79603dbc2f65f2.zip
Rejection sampling to avoid indeterminate gradients in feTurbulence.
(bzr r13844)
Diffstat (limited to 'src')
-rw-r--r--src/display/nr-filter-turbulence.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp
index a2a8c5756..19dedb67c 100644
--- a/src/display/nr-filter-turbulence.cpp
+++ b/src/display/nr-filter-turbulence.cpp
@@ -64,8 +64,10 @@ public:
for (i = 0; i < BSize; ++i) {
_latticeSelector[i] = i;
- _gradient[i][k][0] = static_cast<double>(_random() % (BSize*2) - BSize) / BSize;
- _gradient[i][k][1] = static_cast<double>(_random() % (BSize*2) - BSize) / BSize;
+ do {
+ _gradient[i][k][0] = static_cast<double>(_random() % (BSize*2) - BSize) / BSize;
+ _gradient[i][k][1] = static_cast<double>(_random() % (BSize*2) - BSize) / BSize;
+ } while(_gradient[i][k][0] == 0 && _gradient[i][k][1] == 0);
// normalize gradient
double s = hypot(_gradient[i][k][0], _gradient[i][k][1]);