Hooked up rotation and opacity

This commit is contained in:
Robert committed 2020-01-15 20:06:07 +01:00
1 parent ae330c3769
commit 5069be4af4
9 files changed
+202 -137

No files matched your search

@@ -15,7 +15,7 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
var nextKeyframe = (Keyframe<int>) NextKeyframe;
var diff = nextKeyframe.Value - currentKeyframe.Value;
return currentKeyframe.Value + diff * KeyframeProgressEased;
return (int) Math.Round(currentKeyframe.Value + diff * KeyframeProgressEased, MidpointRounding.AwayFromZero);
}
}
}
+13 -3
View File
@@ -132,12 +132,12 @@ namespace Artemis.Core.Models.Profile
public LayerProperty<SKSize> SizeProperty { get; private set; }
/// <summary>
/// The rotation property of this layer, also found in <see cref="Properties" />
/// The rotation property of this layer range 0 - 360, also found in <see cref="Properties" />
/// </summary>
public LayerProperty<int> RotationProperty { get; private set; }
/// <summary>
/// The opacity property of this layer, also found in <see cref="Properties" />
/// The opacity property of this layer range 0 - 100, also found in <see cref="Properties" />
/// </summary>
public LayerProperty<float> OpacityProperty { get; private set; }
@@ -158,9 +158,19 @@ namespace Artemis.Core.Models.Profile
canvas.Save();
canvas.ClipPath(Path);
// Apply transformations
var rotation = RotationProperty.CurrentValue;
var anchor = AnchorPointProperty.CurrentValue;
if (rotation != 0)
canvas.RotateDegrees(rotation, anchor.X * AbsoluteRectangle.Width + LayerShape.RenderRectangle.Left, anchor.Y * AbsoluteRectangle.Height + LayerShape.RenderRectangle.Top);
// Placeholder
if (LayerShape?.RenderPath != null)
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Color = new SKColor(255, 0, 0)});
{
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Color = new SKColor(255, 0, 0, (byte) (2.55 * OpacityProperty.CurrentValue))});
}
LayerBrush?.Render(canvas);
canvas.Restore();
}
@@ -17,14 +17,17 @@ namespace Artemis.Core.Models.Profile.LayerShapes
{
var width = Layer.AbsoluteRectangle.Width;
var height = Layer.AbsoluteRectangle.Height;
var rect = SKRect.Create(shapePosition.X * width, shapePosition.Y * height, shapeSize.Width * width, shapeSize.Height * height);
var rect = SKRect.Create(
Layer.Rectangle.Left + shapePosition.X * width,
Layer.Rectangle.Top + shapePosition.Y * height,
shapeSize.Width * width,
shapeSize.Height * height
);
var path = new SKPath();
path.AddOval(rect);
path.Transform(SKMatrix.MakeTranslation(Layer.Rectangle.Left, Layer.Rectangle.Top));
RenderPath = path;
RenderRectangle = path.GetRect();
RenderRectangle = rect;
}
public override void ApplyToEntity()
@@ -17,13 +17,17 @@ namespace Artemis.Core.Models.Profile.LayerShapes
{
var width = Layer.AbsoluteRectangle.Width;
var height = Layer.AbsoluteRectangle.Height;
var rect = SKRect.Create(shapePosition.X * width, shapePosition.Y * height, shapeSize.Width * width, shapeSize.Height * height);
var rect = SKRect.Create(
Layer.Rectangle.Left + shapePosition.X * width,
Layer.Rectangle.Top + shapePosition.Y * height,
shapeSize.Width * width,
shapeSize.Height * height
);
var path = new SKPath();
path.AddRect(rect);
path.Transform(SKMatrix.MakeTranslation(Layer.Rectangle.Left, Layer.Rectangle.Top));
RenderPath = path;
RenderRectangle = path.GetRect();
RenderRectangle = rect;
}
public override void ApplyToEntity()