Added layer shapes, editor is still WIP

This commit is contained in:
SpoinkyNL committed 2019-12-15 22:52:04 +01:00
1 parent 70bf0e1c43
commit ddce69e8f0
115 files changed
+1949 -1189

No files matched your search

@@ -7,8 +7,8 @@
<ProjectGuid>{7F4C7AB0-4C9B-452D-AFED-34544C903DEF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Artemis.Plugins.LayerElements.Noise</RootNamespace>
<AssemblyName>Artemis.Plugins.LayerElements.Noise</AssemblyName>
<RootNamespace>Artemis.Plugins.LayerBrushes.Noise</RootNamespace>
<AssemblyName>Artemis.Plugins.LayerBrushes.Noise</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
@@ -87,11 +87,11 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="NoiseLayerElementSettings.cs" />
<Compile Include="NoiseLayerElementViewModel.cs" />
<Compile Include="NoiseLayerElement.cs" />
<Compile Include="NoiseLayerElementProvider.cs" />
<Compile Include="OpenSimplexNoise.cs" />
<Compile Include="NoiseBrushSettings.cs" />
<Compile Include="NoiseBrushViewModel.cs" />
<Compile Include="NoiseBrush.cs" />
<Compile Include="NoiseBrushProvider.cs" />
<Compile Include="Utilities\OpenSimplexNoise.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -113,7 +113,7 @@
</None>
</ItemGroup>
<ItemGroup>
<Page Include="NoiseLayerElementView.xaml">
<Page Include="NoiseBrushView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -1,26 +1,27 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Plugins.LayerBrushes.Noise.Utilities;
using SkiaSharp;
namespace Artemis.Plugins.LayerElements.Noise
namespace Artemis.Plugins.LayerBrushes.Noise
{
public class NoiseLayerElement : LayerElement
public class NoiseBrush : LayerBrush
{
private const int Scale = 6;
private static readonly Random Rand = new Random();
private readonly OpenSimplexNoise _noise;
private float _z;
public NoiseLayerElement(Layer layer, Guid guid, NoiseLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
public NoiseBrush(Layer layer, NoiseBrushSettings settings, LayerBrushDescriptor descriptor) : base(layer, settings, descriptor)
{
Settings = settings;
_z = Rand.Next(0, 4096);
_noise = new OpenSimplexNoise(Guid.GetHashCode());
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
}
public new NoiseLayerElementSettings Settings { get; }
public new NoiseBrushSettings Settings { get; }
public override void Update(double deltaTime)
@@ -34,16 +35,16 @@ namespace Artemis.Plugins.LayerElements.Noise
base.Update(deltaTime);
}
public override LayerElementViewModel GetViewModel()
public override LayerBrushViewModel GetViewModel()
{
return new NoiseLayerElementViewModel(this);
return new NoiseBrushViewModel(this);
}
public override void Render(SKPath framePath, SKCanvas canvas)
public override void Render(SKCanvas canvas)
{
// Scale down the render path to avoid computing a value for every pixel
var width = (int) (Math.Max(Layer.RenderRectangle.Width, Layer.RenderRectangle.Height) / Scale);
var height = (int) (Math.Max(Layer.RenderRectangle.Width, Layer.RenderRectangle.Height) / Scale);
var width = (int) (Math.Max(Layer.Rectangle.Width, Layer.Rectangle.Height) / Scale);
var height = (int) (Math.Max(Layer.Rectangle.Width, Layer.Rectangle.Height) / Scale);
var opacity = (float) Math.Round(Settings.Color.Alpha / 255.0, 2, MidpointRounding.AwayFromZero);
using (var bitmap = new SKBitmap(new SKImageInfo(width, height)))
{
@@ -76,7 +77,7 @@ namespace Artemis.Plugins.LayerElements.Noise
using (var sh = SKShader.CreateBitmap(bitmap, SKShaderTileMode.Mirror, SKShaderTileMode.Mirror, SKMatrix.MakeScale(Scale, Scale)))
using (var paint = new SKPaint {Shader = sh, BlendMode = Settings.BlendMode})
{
canvas.DrawPath(framePath, paint);
canvas.DrawPath(Layer.LayerShape.RenderPath, paint);
}
}
}
@@ -0,0 +1,26 @@
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerBrushes.Noise
{
public class NoiseBrushProvider : LayerBrushProvider
{
public NoiseBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
}
public override void EnablePlugin()
{
}
public override void DisablePlugin()
{
}
public override void Dispose()
{
}
}
}
@@ -1,9 +1,9 @@
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.LayerBrush;
using SkiaSharp;
namespace Artemis.Plugins.LayerElements.Noise
namespace Artemis.Plugins.LayerBrushes.Noise
{
public class NoiseLayerElementSettings : LayerElementSettings
public class NoiseBrushSettings : LayerBrushSettings
{
private float _animationSpeed;
private SKBlendMode _blendMode;
@@ -11,7 +11,7 @@ namespace Artemis.Plugins.LayerElements.Noise
private float _xScale;
private float _yScale;
public NoiseLayerElementSettings()
public NoiseBrushSettings()
{
// Color = new SKColor(0, 0, 0);
// BlendMode = SKBlendMode.Color;
@@ -1,14 +1,14 @@
<UserControl x:Class="Artemis.Plugins.LayerElements.Noise.NoiseLayerElementView"
<UserControl x:Class="Artemis.Plugins.LayerBrushes.Noise.NoiseBrushView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:noiseLayer="clr-namespace:Artemis.Plugins.LayerElements.Noise"
xmlns:artemis="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
xmlns:noiseBrush="clr-namespace:Artemis.Plugins.LayerBrushes.Noise"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type noiseLayer:NoiseLayerElementViewModel}}">
d:DataContext="{d:DesignInstance {x:Type noiseBrush:NoiseBrushViewModel}}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -41,7 +41,7 @@
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Text="Noise color" />
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<artemis:ColorPicker Color="{Binding LayerElement.Settings.Color, Converter={StaticResource SKColorToColorConverter}}" Width="100" />
<artemis:ColorPicker Color="{Binding Brush.Settings.Color, Converter={StaticResource SKColorToColorConverter}}" Width="100" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid>
@@ -69,7 +69,7 @@
SelectedValuePath="Value"
DisplayMemberPath="Description"
Width="100"
SelectedValue="{Binding LayerElement.Settings.BlendMode}" />
SelectedValue="{Binding Brush.Settings.BlendMode}" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid>
@@ -89,7 +89,7 @@
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding LayerElement.Settings.XScale}" Width="100" />
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding Brush.Settings.XScale}" Width="100" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid>
@@ -110,7 +110,7 @@
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding LayerElement.Settings.YScale}" Width="100" />
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding Brush.Settings.YScale}" Width="100" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid>
@@ -132,7 +132,7 @@
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Slider Orientation="Horizontal" TickFrequency="1" Minimum="1" Maximum="100" Value="{Binding LayerElement.Settings.AnimationSpeed}" Width="100" />
<Slider Orientation="Horizontal" TickFrequency="1" Minimum="1" Maximum="100" Value="{Binding Brush.Settings.AnimationSpeed}" Width="100" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid>
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Utilities;
using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.Noise
{
public class NoiseBrushViewModel : LayerBrushViewModel
{
public NoiseBrushViewModel(NoiseBrush brush) : base(brush)
{
Brush = brush;
}
public new NoiseBrush Brush { get; }
public IEnumerable<ValueDescription> BlendModes => EnumUtilities.GetAllValuesAndDescriptions(typeof(SKBlendMode));
}
}
@@ -1,25 +0,0 @@
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerElements.Noise
{
public class NoiseLayerElementProvider : LayerElementProvider
{
public NoiseLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
AddLayerElementDescriptor<NoiseLayerElement>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
}
public override void EnablePlugin()
{
}
public override void DisablePlugin()
{
}
public override void Dispose()
{
}
}
}
@@ -1,18 +0,0 @@
using System.Collections.Generic;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Utilities;
using SkiaSharp;
namespace Artemis.Plugins.LayerElements.Noise
{
public class NoiseLayerElementViewModel : LayerElementViewModel
{
public NoiseLayerElementViewModel(NoiseLayerElement layerElement) : base(layerElement)
{
LayerElement = layerElement;
}
public new NoiseLayerElement LayerElement { get; }
public IEnumerable<ValueDescription> BlendModes => EnumUtilities.GetAllValuesAndDescriptions(typeof(SKBlendMode));
}
}
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Artemis.Plugins.LayerElements.Noise")]
[assembly: AssemblyTitle("Artemis.Plugins.LayerBrushes.Noise")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
@@ -1,7 +1,7 @@
using System;
using System.Runtime.CompilerServices;
namespace Artemis.Plugins.LayerElements.Noise
namespace Artemis.Plugins.LayerBrushes.Noise.Utilities
{
public class OpenSimplexNoise
{
@@ -1,10 +1,10 @@
{
"Guid": "61cbbf01-8d69-4ede-a972-f3f269da66d9",
"Name": "Noise layer elements",
"Name": "Noise layer brush",
"Version": {
"Major": 1,
"Minor": 0,
"Build": 0
},
"Main": "Artemis.Plugins.LayerElements.Noise.dll"
"Main": "Artemis.Plugins.LayerBrushes.Noise.dll"
}