summaryrefslogtreecommitdiffstats
path: root/src/sp-ellipse.cpp
diff options
context:
space:
mode:
authorJabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es>2017-12-05 12:48:06 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es>2017-12-05 12:48:06 +0000
commitc0a73d338290a417a79005a296d8975e12429fb2 (patch)
treef9dd2c315a4e42fd615aa60e1562dc434c78af5b /src/sp-ellipse.cpp
parentAdd fix to problem switching pen tool modes (diff)
parentAttemp to fix compile bug (diff)
downloadinkscape-c0a73d338290a417a79005a296d8975e12429fb2.tar.gz
inkscape-c0a73d338290a417a79005a296d8975e12429fb2.zip
Merge branch 'master' into pen-tool-mode-fixes
Diffstat (limited to 'src/sp-ellipse.cpp')
-rw-r--r--src/sp-ellipse.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 166237c8e..c32e3012c 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -721,6 +721,65 @@ bool SPGenericEllipse::_isSlice() const
return !(Geom::are_near(a.extent(), 0) || Geom::are_near(a.extent(), SP_2PI));
}
+/**
+Returns the ratio in which the vector from p0 to p1 is stretched by transform
+ */
+gdouble SPGenericEllipse::vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform) {
+ if (p0 == p1) {
+ return 0;
+ }
+
+ return (Geom::distance(p0 * xform, p1 * xform) / Geom::distance(p0, p1));
+}
+
+void SPGenericEllipse::setVisibleRx(gdouble rx) {
+ if (rx == 0) {
+ this->rx.unset();
+ } else {
+ this->rx = rx / SPGenericEllipse::vectorStretch(
+ Geom::Point(this->cx.computed + 1, this->cy.computed),
+ Geom::Point(this->cx.computed, this->cy.computed),
+ this->i2doc_affine());
+ }
+
+ this->updateRepr();
+}
+
+void SPGenericEllipse::setVisibleRy(gdouble ry) {
+ if (ry == 0) {
+ this->ry.unset();
+ } else {
+ this->ry = ry / SPGenericEllipse::vectorStretch(
+ Geom::Point(this->cx.computed, this->cy.computed + 1),
+ Geom::Point(this->cx.computed, this->cy.computed),
+ this->i2doc_affine());
+ }
+
+ this->updateRepr();
+}
+
+gdouble SPGenericEllipse::getVisibleRx() const {
+ if (!this->rx._set) {
+ return 0;
+ }
+
+ return this->rx.computed * SPGenericEllipse::vectorStretch(
+ Geom::Point(this->cx.computed + 1, this->cy.computed),
+ Geom::Point(this->cx.computed, this->cy.computed),
+ this->i2doc_affine());
+}
+
+gdouble SPGenericEllipse::getVisibleRy() const {
+ if (!this->ry._set) {
+ return 0;
+ }
+
+ return this->ry.computed * SPGenericEllipse::vectorStretch(
+ Geom::Point(this->cx.computed, this->cy.computed + 1),
+ Geom::Point(this->cx.computed, this->cy.computed),
+ this->i2doc_affine());
+}
+
/*
Local Variables:
mode:c++