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:
commit
9e16605e6b
@ -8,6 +8,7 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
{
|
||||
public class NoiseLayerElement : LayerElement
|
||||
{
|
||||
private static Random _rand = new Random();
|
||||
private readonly OpenSimplexNoise _noise;
|
||||
private float _z;
|
||||
|
||||
@ -15,7 +16,7 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
{
|
||||
Settings = settings;
|
||||
|
||||
_z = 0.001f;
|
||||
_z = 1;
|
||||
_noise = new OpenSimplexNoise(Guid.GetHashCode());
|
||||
}
|
||||
|
||||
@ -24,7 +25,12 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -35,16 +41,19 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
|
||||
public override void Render(ArtemisSurface surface, SKCanvas canvas)
|
||||
{
|
||||
var width = Layer.AbsoluteRenderRectangle.Width / 2;
|
||||
var height = Layer.AbsoluteRenderRectangle.Height / 2;
|
||||
// Scale down the render path
|
||||
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)))
|
||||
{
|
||||
for (var x = 0; x < width; x++)
|
||||
{
|
||||
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);
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
{
|
||||
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()
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
BlendMode = SKBlendMode.Color;
|
||||
XScale = 0.5f;
|
||||
YScale = 0.5f;
|
||||
AnimationSpeed = 0.1f;
|
||||
AnimationSpeed = 50f;
|
||||
}
|
||||
|
||||
public float XScale
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">X Scale</TextBlock>
|
||||
</StackPanel>
|
||||
<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>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -85,7 +85,7 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Y Scale</TextBlock>
|
||||
</StackPanel>
|
||||
<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>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -104,7 +104,7 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Animation speed</TextBlock>
|
||||
</StackPanel>
|
||||
<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>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user