mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 02:33:32 +00:00
Shape tools now take active transformations into consideration
This commit is contained in:
parent
fabb385556
commit
c3a11386b4
@ -230,17 +230,22 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
var scaled = _layerEditorService.GetScaledPoint(layer, countered[1], false);
|
var scaled = _layerEditorService.GetScaledPoint(layer, countered[1], false);
|
||||||
|
|
||||||
// Update the anchor point, this causes the shape to move
|
// Update the anchor point, this causes the shape to move
|
||||||
layer.AnchorPointProperty.SetCurrentValue(scaled, ProfileEditorService.CurrentTime);
|
layer.AnchorPointProperty.SetCurrentValue(RoundPoint(scaled, 5), ProfileEditorService.CurrentTime);
|
||||||
// TopLeft is not updated yet and acts as a snapshot of the top-left before changing the anchor
|
// TopLeft is not updated yet and acts as a snapshot of the top-left before changing the anchor
|
||||||
var path = _layerEditorService.GetLayerPath(layer, true, true, true);
|
var path = _layerEditorService.GetLayerPath(layer, true, true, true);
|
||||||
// Calculate the (scaled) difference between the old and now position
|
// Calculate the (scaled) difference between the old and now position
|
||||||
var difference = _layerEditorService.GetScaledPoint(layer, TopLeft - path.Points[0], false);
|
var difference = _layerEditorService.GetScaledPoint(layer, TopLeft - path.Points[0], false);
|
||||||
// Apply the difference so that the shape effectively stays in place
|
// Apply the difference so that the shape effectively stays in place
|
||||||
layer.PositionProperty.SetCurrentValue(layer.PositionProperty.CurrentValue + difference, ProfileEditorService.CurrentTime);
|
layer.PositionProperty.SetCurrentValue(RoundPoint(layer.PositionProperty.CurrentValue + difference, 5), ProfileEditorService.CurrentTime);
|
||||||
|
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SKPoint RoundPoint(SKPoint point, int decimals)
|
||||||
|
{
|
||||||
|
return new SKPoint((float) Math.Round(point.X, decimals, MidpointRounding.AwayFromZero), (float) Math.Round(point.Y, decimals, MidpointRounding.AwayFromZero));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Size
|
#region Size
|
||||||
|
|||||||
@ -169,6 +169,20 @@ namespace Artemis.UI.Services
|
|||||||
layerShape.ScaledRectangle = SKRect.Empty;
|
layerShape.ScaledRectangle = SKRect.Empty;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var layerRect = GetLayerRenderRect(layerShape.Layer).ToSKRect();
|
||||||
|
|
||||||
|
// Compensate for the current value of the position transformation
|
||||||
|
rect.X += rect.Width / 2;
|
||||||
|
rect.X -= layerRect.Width * layerShape.Layer.PositionProperty.CurrentValue.X;
|
||||||
|
rect.X += layerRect.Width * layerShape.Layer.AnchorPointProperty.CurrentValue.X * layerShape.Layer.SizeProperty.CurrentValue.Width;
|
||||||
|
|
||||||
|
rect.Y += rect.Height / 2;
|
||||||
|
rect.Y -= layerRect.Height * layerShape.Layer.PositionProperty.CurrentValue.Y;
|
||||||
|
rect.Y += layerRect.Height * layerShape.Layer.AnchorPointProperty.CurrentValue.Y * layerShape.Layer.SizeProperty.CurrentValue.Height;
|
||||||
|
|
||||||
|
// Compensate for the current value of the size transformation
|
||||||
|
rect.Height /= layerShape.Layer.SizeProperty.CurrentValue.Height;
|
||||||
|
rect.Width /= layerShape.Layer.SizeProperty.CurrentValue.Width;
|
||||||
|
|
||||||
// Adjust the provided rect for the difference in render scale
|
// Adjust the provided rect for the difference in render scale
|
||||||
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user