summaryrefslogtreecommitdiffstats
path: root/src/sp-gradient.cpp
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-09-19 01:52:19 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-09-19 01:52:19 +0000
commitbf7c3e8d98b557cb64447804399797d93e1cedc0 (patch)
tree80848f225cad4c163c32ce4d2ec963982558adba /src/sp-gradient.cpp
parentFix for 900602 : Enter key returns focus to canvas for Font family selector (diff)
downloadinkscape-bf7c3e8d98b557cb64447804399797d93e1cedc0.tar.gz
inkscape-bf7c3e8d98b557cb64447804399797d93e1cedc0.zip
Fix for 643150 : Auto-palette swatches duplicated on copy and paste
(bzr r11677)
Diffstat (limited to 'src/sp-gradient.cpp')
-rw-r--r--src/sp-gradient.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 262c35db1..5efa3c84f 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -346,6 +346,41 @@ void SPGradient::setSwatch( bool swatch )
}
}
+
+/**
+ * return true if this gradient is "equivalent" to that gradient.
+ * Equivalent meaning they have the same stop count, same stop colors and same stop opacity
+ * @param that - A gradient to compare this to
+ */
+gboolean SPGradient::isEquivalent(SPGradient *that)
+{
+ //TODO Make this work for mesh gradients
+
+ if (this->getStopCount() != that->getStopCount())
+ return FALSE;
+
+ if (this->hasStops() != that->hasStops())
+ return FALSE;
+
+ if (!this->getVector() || !that->getVector())
+ return FALSE;
+
+ SPStop *as = this->getVector()->getFirstStop();
+ SPStop *bs = that->getVector()->getFirstStop();
+
+ while (as && bs) {
+ if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) ||
+ as->offset != bs->offset) {
+ return FALSE;
+ }
+ as = as->getNextStop();
+ bs = bs->getNextStop();
+ }
+
+ return TRUE;
+}
+
+
/**
* Return stop's color as 32bit value.
*/
@@ -2211,6 +2246,7 @@ sp_meshgradient_repr_write(SPMeshGradient *mg)
mg->array.write( mg );
}
+
/*
Local Variables:
mode:c++