Brushes - Allow hiding of properties

This commit is contained in:
SpoinkyNL committed 2020-04-21 20:53:24 +02:00
1 parent 9f8fc9f70e
commit 26f9e90fa3
8 files changed
+113 -47

No files matched your search

@@ -19,11 +19,18 @@ namespace Artemis.Plugins.LayerBrushes.Color
{
GradientTypeProperty = RegisterLayerProperty("Brush.GradientType", "Gradient type", "The type of color brush to draw", GradientType.Solid);
GradientTypeProperty.CanUseKeyframes = false;
ColorProperty = RegisterLayerProperty("Brush.Color", "Color", "The color of the brush", new SKColor(255, 0, 0));
GradientProperty = RegisterLayerProperty("Brush.Gradient", "Gradient", "The gradient of the brush", new ColorGradient());
GradientProperty.CanUseKeyframes = false;
if (!GradientProperty.Value.Stops.Any())
GradientProperty.Value.MakeFabulous();
UpdateColorProperties();
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
GradientTypeProperty.ValueChanged += (sender, args) => UpdateColorProperties();
ColorProperty.ValueChanged += (sender, args) => CreateShader();
GradientProperty.Value.PropertyChanged += (sender, args) => CreateShader();
}
public LayerProperty<SKColor> ColorProperty { get; set; }
@@ -57,23 +64,9 @@ namespace Artemis.Plugins.LayerBrushes.Color
private void UpdateColorProperties()
{
if (GradientTypeProperty.Value == GradientType.Solid)
{
UnRegisterLayerProperty(GradientProperty);
ColorProperty = RegisterLayerProperty("Brush.Color", "Color", "The color of the brush", new SKColor(255, 0, 0));
ColorProperty.ValueChanged += (sender, args) => CreateShader();
}
else
{
UnRegisterLayerProperty(ColorProperty);
GradientProperty = RegisterLayerProperty("Brush.Gradient", "Gradient", "The gradient of the brush", new ColorGradient());
GradientProperty.CanUseKeyframes = false;
GradientProperty.Value.PropertyChanged += (sender, args) => CreateShader();
if (!GradientProperty.Value.Stops.Any())
GradientProperty.Value.MakeFabulous();
}
ColorProperty.IsHidden = GradientTypeProperty.Value != GradientType.Solid;
GradientProperty.IsHidden = GradientTypeProperty.Value == GradientType.Solid;
CreateShader();
}
@@ -30,11 +30,11 @@ namespace Artemis.Plugins.LayerBrushes.Noise
_y = Rand.Next(0, 4096);
_z = Rand.Next(0, 4096);
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
DetermineRenderScale();
ColorTypeProperty = RegisterLayerProperty("Brush.ColorType", "Color mapping type", "The way the noise is converted to colors", ColorMappingType.Simple);
ColorTypeProperty.CanUseKeyframes = false;
ColorTypeProperty.ValueChanged += (sender, args) => UpdateColorProperties();
UpdateColorProperties();
ScaleProperty = RegisterLayerProperty("Brush.Scale", "Scale", "The scale of the noise.", new SKSize(100, 100));
ScaleProperty.MinInputValue = 0f;
HardnessProperty = RegisterLayerProperty("Brush.Hardness", "Hardness", "The hardness of the noise, lower means there are gradients in the noise, higher means hard lines", 500f);
@@ -47,8 +47,16 @@ namespace Artemis.Plugins.LayerBrushes.Noise
AnimationSpeedProperty.MinInputValue = 0f;
AnimationSpeedProperty.MaxInputValue = 64f;
ScaleProperty.InputAffix = "%";
MainColorProperty = RegisterLayerProperty("Brush.MainColor", "Main color", "The main color of the noise", new SKColor(255, 0, 0));
SecondaryColorProperty = RegisterLayerProperty("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise", new SKColor(0, 0, 255));
GradientColorProperty = RegisterLayerProperty("Brush.GradientColor", "Noise gradient map", "The gradient the noise will map it's value to", new ColorGradient());
GradientColorProperty.CanUseKeyframes = false;
if (!GradientColorProperty.Value.Stops.Any())
GradientColorProperty.Value.MakeFabulous();
GradientColorProperty.Value.PropertyChanged += CreateColorMap;
DetermineRenderScale();
UpdateColorProperties();
CreateColorMap(null, null);
}
@@ -64,25 +72,9 @@ namespace Artemis.Plugins.LayerBrushes.Noise
private void UpdateColorProperties()
{
if (GradientColorProperty != null)
GradientColorProperty.Value.PropertyChanged -= CreateColorMap;
if (ColorTypeProperty.Value == ColorMappingType.Simple)
{
UnRegisterLayerProperty(GradientColorProperty);
MainColorProperty = RegisterLayerProperty("Brush.MainColor", "Main color", "The main color of the noise", new SKColor(255, 0, 0));
SecondaryColorProperty = RegisterLayerProperty("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise", new SKColor(0, 0, 255));
}
else
{
UnRegisterLayerProperty(MainColorProperty);
UnRegisterLayerProperty(SecondaryColorProperty);
GradientColorProperty = RegisterLayerProperty("Brush.GradientColor", "Noise gradient map", "The gradient the noise will map it's value to", new ColorGradient());
if (!GradientColorProperty.Value.Stops.Any())
GradientColorProperty.Value.MakeFabulous();
GradientColorProperty.Value.PropertyChanged += CreateColorMap;
CreateColorMap(null, null);
}
GradientColorProperty.IsHidden = ColorTypeProperty.Value != ColorMappingType.Gradient;
MainColorProperty.IsHidden = ColorTypeProperty.Value != ColorMappingType.Simple;
SecondaryColorProperty.IsHidden = ColorTypeProperty.Value != ColorMappingType.Simple;
}
public override void Update(double deltaTime)
@@ -136,7 +128,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
else if (gradientColor != null && _colorMap.Length == 101)
{
var color = _colorMap[(int) Math.Round(alpha / 255f * 100, MidpointRounding.AwayFromZero)];
_bitmap.SetPixel(x, y, new SKColor(color.Red, color.Green, color.Blue, 255));
_bitmap.SetPixel(x, y, color);
}
}
}