mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Some attempts at proper anchor movement..
This commit is contained in:
1 parent
99c1638907
commit
b2507202bd
6 files changed
+269
-153
No files matched your search
@@ -160,18 +160,22 @@ namespace Artemis.Core.Models.Profile
|
||||
canvas.ClipPath(Path);
|
||||
|
||||
// Apply transformations
|
||||
var anchor = AnchorPointProperty.CurrentValue;
|
||||
var position = PositionProperty.CurrentValue;
|
||||
var size = SizeProperty.CurrentValue;
|
||||
var rotation = RotationProperty.CurrentValue;
|
||||
// Scale the anchor and make it originate from the center of the untranslated layer shape
|
||||
anchor.X = anchor.X * AbsoluteRectangle.Width + LayerShape.RenderRectangle.MidX;
|
||||
anchor.Y = anchor.Y * AbsoluteRectangle.Height + LayerShape.RenderRectangle.MidY;
|
||||
|
||||
canvas.Translate(position.X * AbsoluteRectangle.Width, position.Y * AbsoluteRectangle.Height);
|
||||
var anchor = GetLayerAnchor(true);
|
||||
var relativeAnchor = GetLayerAnchor(false);
|
||||
|
||||
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||
var x = position.X * Rectangle.Width - LayerShape.RenderRectangle.Width / 2 - relativeAnchor.X;
|
||||
var y = position.Y * Rectangle.Height - LayerShape.RenderRectangle.Height / 2 - relativeAnchor.Y;
|
||||
|
||||
|
||||
canvas.RotateDegrees(rotation, anchor.X, anchor.Y);
|
||||
canvas.Scale(size.Width, size.Height, anchor.X, anchor.Y);
|
||||
|
||||
canvas.Translate(x, y);
|
||||
|
||||
// Placeholder
|
||||
if (LayerShape?.RenderPath != null)
|
||||
{
|
||||
@@ -192,6 +196,22 @@ namespace Artemis.Core.Models.Profile
|
||||
canvas.Restore();
|
||||
}
|
||||
|
||||
private SKPoint GetLayerAnchor(bool absolute)
|
||||
{
|
||||
if (!absolute)
|
||||
{
|
||||
var anchor = AnchorPointProperty.CurrentValue;
|
||||
anchor.X = anchor.X * Rectangle.Width;
|
||||
anchor.Y = anchor.Y * Rectangle.Height;
|
||||
return new SKPoint(anchor.X, anchor.Y);
|
||||
}
|
||||
|
||||
var position = PositionProperty.CurrentValue;
|
||||
position.X = position.X * Rectangle.Width;
|
||||
position.Y = position.Y * Rectangle.Height;
|
||||
return new SKPoint(position.X + LayerShape.RenderRectangle.Left, position.Y + LayerShape.RenderRectangle.Top);
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
// Properties
|
||||
|
||||
Reference in new issue
Block a user