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>{0F288A66-6EB0-4589-8595-E33A3A3EAEA2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Artemis.Plugins.LayerElements.Brush</RootNamespace>
<AssemblyName>Artemis.Plugins.LayerElements.Brush</AssemblyName>
<RootNamespace>Artemis.Plugins.LayerBrushes.Color</RootNamespace>
<AssemblyName>Artemis.Plugins.LayerBrushes.Color</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
@@ -87,10 +87,10 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="BrushLayerElementSettings.cs" />
<Compile Include="BrushLayerElementViewModel.cs" />
<Compile Include="BrushLayerElement.cs" />
<Compile Include="BrushLayerElementProvider.cs" />
<Compile Include="ColorBrushSettings.cs" />
<Compile Include="ColorBrushViewModel.cs" />
<Compile Include="ColorBrush.cs" />
<Compile Include="ColorBrushProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -108,7 +108,7 @@
</None>
</ItemGroup>
<ItemGroup>
<Page Include="BrushLayerElementView.xaml">
<Page Include="ColorBrushView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -1,25 +0,0 @@
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerElements.Brush
{
public class BrushLayerElementProvider : LayerElementProvider
{
public BrushLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
AddLayerElementDescriptor<BrushLayerElement>("Brush", "A brush of a specific type and colors", "Brush");
}
public override void EnablePlugin()
{
}
public override void DisablePlugin()
{
}
public override void Dispose()
{
}
}
}
@@ -1,17 +0,0 @@
using System.Collections.Generic;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Utilities;
namespace Artemis.Plugins.LayerElements.Brush
{
public class BrushLayerElementViewModel : LayerElementViewModel
{
public BrushLayerElementViewModel(BrushLayerElement layerElement) : base(layerElement)
{
LayerElement = layerElement;
}
public new BrushLayerElement LayerElement { get; }
public IEnumerable<ValueDescription> BrushTypes => EnumUtilities.GetAllValuesAndDescriptions(typeof(BrushType));
}
}
@@ -2,19 +2,18 @@
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.LayerBrush;
using SkiaSharp;
namespace Artemis.Plugins.LayerElements.Brush
namespace Artemis.Plugins.LayerBrushes.Color
{
public class BrushLayerElement : LayerElement
public class ColorBrush : LayerBrush
{
private SKShader _shader;
private List<SKColor> _testColors;
private SKPaint _paint;
public BrushLayerElement(Layer layer, Guid guid, BrushLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
public ColorBrush(Layer layer, ColorBrushSettings settings, LayerBrushDescriptor descriptor) : base(layer, settings, descriptor)
{
Settings = settings;
@@ -34,20 +33,20 @@ namespace Artemis.Plugins.LayerElements.Brush
private void CreateShader()
{
var center = new SKPoint(Layer.RenderRectangle.MidX, Layer.RenderRectangle.MidY);
var center = new SKPoint(Layer.Rectangle.MidX, Layer.Rectangle.MidY);
SKShader shader;
switch (Settings.BrushType)
switch (Settings.GradientType)
{
case BrushType.Solid:
case GradientType.Solid:
shader = SKShader.CreateColor(_testColors.First());
break;
case BrushType.LinearGradient:
shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(Layer.RenderRectangle.Width, 0), _testColors.ToArray(), SKShaderTileMode.Repeat);
case GradientType.LinearGradient:
shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(Layer.Rectangle.Width, 0), _testColors.ToArray(), SKShaderTileMode.Repeat);
break;
case BrushType.RadialGradient:
shader = SKShader.CreateRadialGradient(center, Math.Min(Layer.RenderRectangle.Width, Layer.RenderRectangle.Height), _testColors.ToArray(), SKShaderTileMode.Repeat);
case GradientType.RadialGradient:
shader = SKShader.CreateRadialGradient(center, Math.Min(Layer.Rectangle.Width, Layer.Rectangle.Height), _testColors.ToArray(), SKShaderTileMode.Repeat);
break;
case BrushType.SweepGradient:
case GradientType.SweepGradient:
shader = SKShader.CreateSweepGradient(center, _testColors.ToArray(), null, SKShaderTileMode.Clamp, 0, 360);
break;
default:
@@ -62,16 +61,16 @@ namespace Artemis.Plugins.LayerElements.Brush
oldPaint?.Dispose();
}
public new BrushLayerElementSettings Settings { get; }
public new ColorBrushSettings Settings { get; }
public override LayerElementViewModel GetViewModel()
public override LayerBrushViewModel GetViewModel()
{
return new BrushLayerElementViewModel(this);
return new ColorBrushViewModel(this);
}
public override void Render(SKPath framePath, SKCanvas canvas)
public override void Render(SKCanvas canvas)
{
canvas.DrawPath(framePath, _paint);
canvas.DrawPath(Layer.LayerShape.RenderPath, _paint);
}
}
}
@@ -0,0 +1,25 @@
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerBrushes.Color
{
public class ColorBrushProvider : LayerBrushProvider
{
public ColorBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
}
public override void EnablePlugin()
{
}
public override void DisablePlugin()
{
}
public override void Dispose()
{
}
}
}
@@ -1,25 +1,25 @@
using System.Collections.Generic;
using System.ComponentModel;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.LayerBrush;
using SkiaSharp;
namespace Artemis.Plugins.LayerElements.Brush
namespace Artemis.Plugins.LayerBrushes.Color
{
public class BrushLayerElementSettings : LayerElementSettings
public class ColorBrushSettings : LayerBrushSettings
{
private BrushType _brushType;
private List<SKColor> _colors;
private GradientType _gradientType;
public BrushLayerElementSettings()
public ColorBrushSettings()
{
BrushType = BrushType.Solid;
GradientType = GradientType.Solid;
Colors = new List<SKColor>();
}
public BrushType BrushType
public GradientType GradientType
{
get => _brushType;
set => SetAndNotify(ref _brushType, value);
get => _gradientType;
set => SetAndNotify(ref _gradientType, value);
}
public List<SKColor> Colors
@@ -29,7 +29,7 @@ namespace Artemis.Plugins.LayerElements.Brush
}
}
public enum BrushType
public enum GradientType
{
[Description("Solid")]
Solid,
@@ -1,13 +1,12 @@
<UserControl x:Class="Artemis.Plugins.LayerElements.Brush.BrushLayerElementView"
<UserControl x:Class="Artemis.Plugins.LayerBrushes.Color.ColorBrushView"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:brushLayer="clr-namespace:Artemis.Plugins.LayerElements.Brush"
xmlns:colorBrush="clr-namespace:Artemis.Plugins.LayerBrushes.Color"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type brushLayer:BrushLayerElementViewModel}}">
d:DataContext="{d:DesignInstance {x:Type colorBrush:ColorBrushViewModel}}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -47,7 +46,7 @@
ItemsSource="{Binding Path=BrushTypes}"
SelectedValuePath="Value"
DisplayMemberPath="Description"
SelectedValue="{Binding Path=LayerElement.Settings.BrushType}" />
SelectedValue="{Binding Path=ColorBrush.Settings.GradientType}" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid>
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Utilities;
namespace Artemis.Plugins.LayerBrushes.Color
{
public class ColorBrushViewModel : LayerBrushViewModel
{
public ColorBrushViewModel(ColorBrush element) : base(element)
{
ColorBrush = element;
}
public new ColorBrush ColorBrush { get; }
public IEnumerable<ValueDescription> BrushTypes => EnumUtilities.GetAllValuesAndDescriptions(typeof(GradientType));
}
}
@@ -4,7 +4,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.Brush")]
[assembly: AssemblyTitle("Artemis.Plugins.LayerBrushes.Color")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
@@ -1,10 +1,10 @@
{
"Guid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a",
"Name": "Brush layer elements",
"Name": "Color layer brush",
"Version": {
"Major": 1,
"Minor": 0,
"Build": 0
},
"Main": "Artemis.Plugins.LayerElements.Brush.dll"
"Main": "Artemis.Plugins.LayerBrushes.Color.dll"
}