You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get or calculate a SvgVisualElement's absolute position relative to the document. I kluged the SvgElement.PushTransforms (listed below) in an attempt to track translates in _this.ptAbsoluteXY
It worked until I tested a rotate on center transform which over inflates _ptAbsoluteXY.
Then I thought maybe subtract any Matrix OffsetX/OffsetY value from _ptAbsoluteXY when dealing with SvgRotate???
There has to be a better way, something I'm missing for sure!?! Is there any way to get the absolute values from GetBounds() or other method?
Many thanks for your help!
protected internal virtual bool PushTransforms(ISvgRenderer renderer) {
_graphicsMatrix = renderer.Transform;
_graphicsClip = renderer.GetClip();
//OSS:Enh:_ptAbsoluteXY tracks Svg transformed position
if (renderer.Transform.OffsetX != 0 || renderer.Transform.OffsetY != 0) {
if (this._ptAbsoluteXY.X != renderer.Transform.OffsetX || this._ptAbsoluteXY.Y != renderer.Transform.OffsetY)
this._ptAbsoluteXY = new PointF(renderer.Transform.OffsetX, renderer.Transform.OffsetY);
}
// Return if there are no transforms
if (this.Transforms == null || this.Transforms.Count == 0) {
return true;
}
if (this.Transforms.Count == 1 && this.Transforms[0].Matrix.Equals(_zeroMatrix)) return false;
Matrix transformMatrix = renderer.Transform.Clone();
float fTrackRotateOffsetX = 0, fTrackRotateOffsetY = 0;
foreach (SvgTransform transformation in this.Transforms) {
transformMatrix.Multiply(transformation.Matrix);
//OSS:Fix:_ptAbsoluteXY only track translates NOT applied to rotations???
if (transformation is SvgRotate) {
fTrackRotateOffsetX += transformation.Matrix.OffsetX;
fTrackRotateOffsetY += transformation.Matrix.OffsetY;
}
}
renderer.Transform = transformMatrix;
//OSS:Enh:_ptAbsoluteXY tracks Svg transformed position
if (transformMatrix.OffsetX != 0 || transformMatrix.OffsetY != 0) {
this._ptAbsoluteXY = new PointF(transformMatrix.OffsetX - fTrackRotateOffsetX, transformMatrix.OffsetY - fTrackRotateOffsetY);
}
return true;
}
This discussion was converted from issue #235 on April 11, 2022 18:47.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to get or calculate a SvgVisualElement's absolute position relative to the document. I kluged the SvgElement.PushTransforms (listed below) in an attempt to track translates in _this.ptAbsoluteXY
It worked until I tested a rotate on center transform which over inflates _ptAbsoluteXY.
Then I thought maybe subtract any Matrix OffsetX/OffsetY value from _ptAbsoluteXY when dealing with SvgRotate???
There has to be a better way, something I'm missing for sure!?! Is there any way to get the absolute values from GetBounds() or other method?
Many thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions