1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Robert 2019-12-06 17:34:12 +01:00
commit 9e16605e6b
4 changed files with 19 additions and 10 deletions

View File

@ -8,6 +8,7 @@ namespace Artemis.Plugins.LayerElements.Noise
{ {
public class NoiseLayerElement : LayerElement public class NoiseLayerElement : LayerElement
{ {
private static Random _rand = new Random();
private readonly OpenSimplexNoise _noise; private readonly OpenSimplexNoise _noise;
private float _z; private float _z;
@ -15,7 +16,7 @@ namespace Artemis.Plugins.LayerElements.Noise
{ {
Settings = settings; Settings = settings;
_z = 0.001f; _z = 1;
_noise = new OpenSimplexNoise(Guid.GetHashCode()); _noise = new OpenSimplexNoise(Guid.GetHashCode());
} }
@ -24,7 +25,12 @@ namespace Artemis.Plugins.LayerElements.Noise
public override void Update(double deltaTime) public override void Update(double deltaTime)
{ {
_z += Settings.AnimationSpeed; // TODO: Come up with a better way to use deltaTime
_z += Settings.AnimationSpeed / 500f / 0.04f * (float) deltaTime;
if (_z >= float.MaxValue)
_z = 0;
base.Update(deltaTime); base.Update(deltaTime);
} }
@ -35,16 +41,19 @@ namespace Artemis.Plugins.LayerElements.Noise
public override void Render(ArtemisSurface surface, SKCanvas canvas) public override void Render(ArtemisSurface surface, SKCanvas canvas)
{ {
var width = Layer.AbsoluteRenderRectangle.Width / 2; // Scale down the render path
var height = Layer.AbsoluteRenderRectangle.Height / 2; var width = Layer.AbsoluteRenderRectangle.Width / 4;
var height = Layer.AbsoluteRenderRectangle.Height / 4;
using (var bitmap = new SKBitmap(new SKImageInfo((int) Layer.AbsoluteRenderRectangle.Width, (int) Layer.AbsoluteRenderRectangle.Height))) using (var bitmap = new SKBitmap(new SKImageInfo((int) Layer.AbsoluteRenderRectangle.Width, (int) Layer.AbsoluteRenderRectangle.Height)))
{ {
for (var x = 0; x < width; x++) for (var x = 0; x < width; x++)
{ {
for (var y = 0; y < height; y++) for (var y = 0; y < height; y++)
{ {
// Not setting pixels outside the layer clip would be faster but right now rotation takes place after the rendering, must change that first
var v = _noise.Evaluate(Settings.XScale * x / width, Settings.YScale * y / height, _z); var v = _noise.Evaluate(Settings.XScale * x / width, Settings.YScale * y / height, _z);
bitmap.SetPixel(x, y, new SKColor(255, 255, 255, (byte) ((v + 1) * 127))); bitmap.SetPixel(x, y, new SKColor(0, 0, 0, (byte) ((v + 1) * 127)));
} }
} }

View File

@ -7,7 +7,7 @@ namespace Artemis.Plugins.LayerElements.Noise
{ {
public NoiseLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo) public NoiseLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
{ {
AddLayerElementDescriptor<NoiseLayerElement>("Noise", "A brush of that shows a perlin noise", "Brush"); AddLayerElementDescriptor<NoiseLayerElement>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
} }
public override void EnablePlugin() public override void EnablePlugin()

View File

@ -16,7 +16,7 @@ namespace Artemis.Plugins.LayerElements.Noise
BlendMode = SKBlendMode.Color; BlendMode = SKBlendMode.Color;
XScale = 0.5f; XScale = 0.5f;
YScale = 0.5f; YScale = 0.5f;
AnimationSpeed = 0.1f; AnimationSpeed = 50f;
} }
public float XScale public float XScale

View File

@ -66,7 +66,7 @@
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">X Scale</TextBlock> <TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">X Scale</TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="20" 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> </StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" /> <Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid> </Grid>
@ -85,7 +85,7 @@
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Y Scale</TextBlock> <TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Y Scale</TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="20" 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> </StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" /> <Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid> </Grid>
@ -104,7 +104,7 @@
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Animation speed</TextBlock> <TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Animation speed</TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Slider Orientation="Horizontal" TickFrequency="0.05" Minimum="0.05" Maximum="1" Value="{Binding LayerElement.Settings.YScale}" Width="100"/> <Slider Orientation="Horizontal" TickFrequency="1" Minimum="1" Maximum="100" Value="{Binding LayerElement.Settings.AnimationSpeed}" Width="100"/>
</StackPanel> </StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" /> <Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
</Grid> </Grid>