mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +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);
|
||||
|
||||
// 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
|
||||
var path = _layerEditorService.GetLayerPath(layer, true, true, true);
|
||||
// Calculate the (scaled) difference between the old and now position
|
||||
var difference = _layerEditorService.GetScaledPoint(layer, TopLeft - path.Points[0], false);
|
||||
// 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();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#region Size
|
||||
|
||||
@ -169,6 +169,20 @@ namespace Artemis.UI.Services
|
||||
layerShape.ScaledRectangle = SKRect.Empty;
|
||||
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
|
||||
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user