mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added shared UI library and finished the ColorPicker
This commit is contained in:
1 parent
5e876dc8ca
commit
b9471abdec
30 files changed
+875
-321
No files matched your search
@@ -100,6 +100,10 @@
|
||||
<Name>Artemis.Core</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj">
|
||||
<Project>{adb357e6-151d-4d0d-87cb-68fd0bc29812}</Project>
|
||||
<Name>Artemis.UI.Shared</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -44,9 +44,10 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
// 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 opacity = (float) Math.Round(Settings.Color.Alpha / 255.0, 2, MidpointRounding.AwayFromZero);
|
||||
using (var bitmap = new SKBitmap(new SKImageInfo(width, height)))
|
||||
{
|
||||
bitmap.Erase(new SKColor(0, 0, 0, 0));
|
||||
// Only compute pixels inside LEDs, due to scaling there may be some rounding issues but it's neglect-able
|
||||
foreach (var artemisLed in Layer.Leds)
|
||||
{
|
||||
@@ -60,13 +61,20 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
for (var y = yStart; y < yEnd; y++)
|
||||
{
|
||||
var v = _noise.Evaluate(Settings.XScale * x / width, Settings.YScale * y / height, _z);
|
||||
bitmap.SetPixel((int) x, (int) y, new SKColor(0, 0, 0, (byte) ((v + 1) * 127)));
|
||||
var alpha = (byte) ((v + 1) * 127 * opacity);
|
||||
// There's some fun stuff we can do here, like creating hard lines
|
||||
// if (alpha > 128)
|
||||
// alpha = 255;
|
||||
// else
|
||||
// alpha = 0;
|
||||
var color = new SKColor(Settings.Color.Red, Settings.Color.Green, Settings.Color.Blue, alpha);
|
||||
bitmap.SetPixel((int) x, (int) y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var sh = SKShader.CreateBitmap(bitmap, SKShaderTileMode.Mirror, SKShaderTileMode.Mirror, SKMatrix.MakeScale(Scale, Scale)))
|
||||
using (var paint = new SKPaint {Shader = sh})
|
||||
using (var paint = new SKPaint {Shader = sh, BlendMode = Settings.BlendMode})
|
||||
{
|
||||
canvas.DrawPath(framePath, paint);
|
||||
}
|
||||
|
||||
@@ -5,18 +5,31 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
{
|
||||
public class NoiseLayerElementSettings : LayerElementSettings
|
||||
{
|
||||
private float _animationSpeed;
|
||||
private SKBlendMode _blendMode;
|
||||
private SKColor _color;
|
||||
private float _xScale;
|
||||
private float _yScale;
|
||||
private float _animationSpeed;
|
||||
|
||||
|
||||
|
||||
public NoiseLayerElementSettings()
|
||||
{
|
||||
BlendMode = SKBlendMode.Color;
|
||||
XScale = 0.5f;
|
||||
YScale = 0.5f;
|
||||
AnimationSpeed = 50f;
|
||||
// Color = new SKColor(0, 0, 0);
|
||||
// BlendMode = SKBlendMode.Color;
|
||||
// XScale = 0.5f;
|
||||
// YScale = 0.5f;
|
||||
// AnimationSpeed = 50f;
|
||||
}
|
||||
|
||||
public SKColor Color
|
||||
{
|
||||
get => _color;
|
||||
set => SetAndNotify(ref _color, value);
|
||||
}
|
||||
|
||||
public SKBlendMode BlendMode
|
||||
{
|
||||
get => _blendMode;
|
||||
set => SetAndNotify(ref _blendMode, value);
|
||||
}
|
||||
|
||||
public float XScale
|
||||
@@ -36,11 +49,5 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
get => _animationSpeed;
|
||||
set => SetAndNotify(ref _animationSpeed, value);
|
||||
}
|
||||
|
||||
public SKBlendMode BlendMode
|
||||
{
|
||||
get => _blendMode;
|
||||
set => SetAndNotify(ref _blendMode, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,18 @@
|
||||
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: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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type noiseLayer:NoiseLayerElementViewModel}}">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Teal.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:SKColorToColorConverter x:Key="SKColorToColorConverter" />
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
@@ -29,6 +28,24 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<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" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
@@ -38,17 +55,21 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Blend mode</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Affects how the noise is rendered on the rest of the layer</TextBlock>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
<Run Text="Blend mode" />
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">
|
||||
<Run Text="Affects how the noise is rendered on the rest of the layer" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ComboBox HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Path=BlendModes}"
|
||||
ItemsSource="{Binding BlendModes}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
Width="100"
|
||||
SelectedValue="{Binding Path=LayerElement.Settings.BlendMode}" />
|
||||
SelectedValue="{Binding LayerElement.Settings.BlendMode}" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@@ -62,11 +83,13 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">X Scale</TextBlock>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
<Run Text="X Scale" />
|
||||
</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 LayerElement.Settings.XScale}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@@ -81,11 +104,13 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Y Scale</TextBlock>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
<Run Text="Y Scale" />
|
||||
</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 LayerElement.Settings.YScale}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@@ -100,11 +125,14 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Animation speed</TextBlock>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
<Run Text="Animation speed" />
|
||||
</TextBlock>
|
||||
</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 LayerElement.Settings.AnimationSpeed}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
Reference in new issue
Block a user