mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Core - Implemented clipping modes
This commit is contained in:
parent
51a21b7a8a
commit
73115898de
@ -219,10 +219,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
StretchRender(canvas, paint);
|
StretchRender(canvas, paint);
|
||||||
break;
|
break;
|
||||||
case LayerFillType.Clip:
|
case LayerFillType.Clip:
|
||||||
ClipRender(canvas, paint);
|
ClipRender(canvas, paint, true);
|
||||||
break;
|
|
||||||
case LayerFillType.Tile:
|
|
||||||
TileRender(canvas, paint);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
@ -247,14 +244,13 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
// Apply these before translation because anchorPosition takes translation into account
|
// Apply these before translation because anchorPosition takes translation into account
|
||||||
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
||||||
canvas.Scale(sizeProperty.Width, sizeProperty.Height, anchorPosition.X, anchorPosition.Y);
|
canvas.Scale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y);
|
||||||
// Once the other transformations are done it is save to translate
|
|
||||||
canvas.Translate(x, y);
|
canvas.Translate(x, y);
|
||||||
|
|
||||||
LayerBrush?.Render(canvas, LayerShape.Path, paint);
|
LayerBrush?.Render(canvas, new SKPath(LayerShape.Path), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClipRender(SKCanvas canvas, SKPaint paint)
|
private void ClipRender(SKCanvas canvas, SKPaint paint, bool rotatePath)
|
||||||
{
|
{
|
||||||
// Apply transformations
|
// Apply transformations
|
||||||
var sizeProperty = ScaleProperty.CurrentValue;
|
var sizeProperty = ScaleProperty.CurrentValue;
|
||||||
@ -263,41 +259,23 @@ namespace Artemis.Core.Models.Profile
|
|||||||
var anchorPosition = GetLayerAnchorPosition();
|
var anchorPosition = GetLayerAnchorPosition();
|
||||||
var anchorProperty = AnchorPointProperty.CurrentValue;
|
var anchorProperty = AnchorPointProperty.CurrentValue;
|
||||||
|
|
||||||
// Translation originates from the unscaled center of the layer and is tied to the anchor
|
|
||||||
var x = anchorPosition.X - Bounds.MidX - anchorProperty.X * Bounds.Width;
|
|
||||||
var y = anchorPosition.Y - Bounds.MidY - anchorProperty.Y * Bounds.Height;
|
|
||||||
|
|
||||||
// Rotation is always applied on the canvas
|
|
||||||
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
|
||||||
|
|
||||||
var path = new SKPath(LayerShape.Path);
|
|
||||||
path.Transform(SKMatrix.MakeTranslation(x, y));
|
|
||||||
path.Transform(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
|
||||||
|
|
||||||
LayerBrush?.Render(canvas, path, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TileRender(SKCanvas canvas, SKPaint paint)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
// Apply transformations
|
|
||||||
var sizeProperty = ScaleProperty.CurrentValue;
|
|
||||||
var rotationProperty = RotationProperty.CurrentValue;
|
|
||||||
|
|
||||||
var anchorPosition = GetLayerAnchorPosition();
|
|
||||||
var anchorProperty = AnchorPointProperty.CurrentValue;
|
|
||||||
|
|
||||||
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||||
var x = anchorPosition.X - Bounds.MidX - anchorProperty.X * Bounds.Width;
|
var x = anchorPosition.X - Bounds.MidX - anchorProperty.X * Bounds.Width;
|
||||||
var y = anchorPosition.Y - Bounds.MidY - anchorProperty.Y * Bounds.Height;
|
var y = anchorPosition.Y - Bounds.MidY - anchorProperty.Y * Bounds.Height;
|
||||||
|
|
||||||
// Apply these before translation because anchorPosition takes translation into account
|
var clipPath = new SKPath(LayerShape.Path);
|
||||||
|
clipPath.Transform(SKMatrix.MakeTranslation(x, y));
|
||||||
|
clipPath.Transform(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||||
|
clipPath.Transform(SKMatrix.MakeRotationDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y));
|
||||||
|
canvas.ClipPath(clipPath);
|
||||||
|
|
||||||
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
||||||
canvas.Scale(sizeProperty.Width, sizeProperty.Height, anchorPosition.X, anchorPosition.Y);
|
|
||||||
// Once the other transformations are done it is save to translate
|
|
||||||
canvas.Translate(x, y);
|
canvas.Translate(x, y);
|
||||||
|
|
||||||
LayerBrush?.Render(canvas, LayerShape.Path, paint);
|
// Render the entire layer, the clip will ensure the shape is matched
|
||||||
|
var renderPath = new SKPath();
|
||||||
|
renderPath.AddRect(Path.Bounds);
|
||||||
|
LayerBrush?.Render(canvas, renderPath, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void CalculateRenderProperties()
|
internal void CalculateRenderProperties()
|
||||||
@ -582,7 +560,6 @@ namespace Artemis.Core.Models.Profile
|
|||||||
public enum LayerFillType
|
public enum LayerFillType
|
||||||
{
|
{
|
||||||
Stretch,
|
Stretch,
|
||||||
Clip,
|
Clip
|
||||||
Tile
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,6 +32,7 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
|||||||
|
|
||||||
CreateShader();
|
CreateShader();
|
||||||
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
||||||
|
GradientTypeProperty.ValueChanged += (sender, args) => CreateShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayerProperty<SKColor> ColorProperty { get; set; }
|
public LayerProperty<SKColor> ColorProperty { get; set; }
|
||||||
|
|||||||
@ -36,14 +36,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
_coreService = coreService;
|
_coreService = coreService;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
_layerPropertyVmFactory = layerPropertyVmFactory;
|
_layerPropertyVmFactory = layerPropertyVmFactory;
|
||||||
|
_layerPropertyViewModels = new List<LayerPropertyViewModel>();
|
||||||
|
|
||||||
PixelsPerSecond = 31;
|
PixelsPerSecond = 31;
|
||||||
PropertyTree = propertyTreeVmFactory.Create(this);
|
PropertyTree = propertyTreeVmFactory.Create(this);
|
||||||
PropertyTimeline = propertyTimelineVmFactory.Create(this);
|
PropertyTimeline = propertyTimelineVmFactory.Create(this);
|
||||||
|
|
||||||
PopulateProperties(_profileEditorService.SelectedProfileElement, null);
|
PopulateProperties(_profileEditorService.SelectedProfileElement, null);
|
||||||
|
|
||||||
_layerPropertyViewModels = new List<LayerPropertyViewModel>();
|
|
||||||
_profileEditorService.SelectedProfileElementChanged += (sender, args) => PopulateProperties(args.ProfileElement, args.PreviousProfileElement);
|
_profileEditorService.SelectedProfileElementChanged += (sender, args) => PopulateProperties(args.ProfileElement, args.PreviousProfileElement);
|
||||||
_profileEditorService.SelectedProfileChanged += (sender, args) => PopulateProperties(_profileEditorService.SelectedProfileElement, null);
|
_profileEditorService.SelectedProfileChanged += (sender, args) => PopulateProperties(_profileEditorService.SelectedProfileElement, null);
|
||||||
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
|
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user