From 4e001d10875f9e6dadc7803ea1d618db4b857eaf Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 21 Jan 2017 23:25:24 +0100 Subject: [PATCH] Added more basic stuff --- RGB.NET.Core/Brushes/BrushCalculationMode.cs | 20 ++++++ RGB.NET.Core/Brushes/BrushRenderTarget.cs | 47 ++++++++++++++ RGB.NET.Core/Brushes/IBrush.cs | 58 +++++++++++++++++ .../ColorCorrection/IColorCorrection.cs | 14 ++++ RGB.NET.Core/Effects/IEffect.cs | 64 +++++++++++++++++++ RGB.NET.Core/Effects/IEffectTarget.cs | 33 ++++++++++ RGB.NET.Core/RGB.NET.Core.csproj | 6 ++ 7 files changed, 242 insertions(+) create mode 100644 RGB.NET.Core/Brushes/BrushCalculationMode.cs create mode 100644 RGB.NET.Core/Brushes/BrushRenderTarget.cs create mode 100644 RGB.NET.Core/Brushes/IBrush.cs create mode 100644 RGB.NET.Core/ColorCorrection/IColorCorrection.cs create mode 100644 RGB.NET.Core/Effects/IEffect.cs create mode 100644 RGB.NET.Core/Effects/IEffectTarget.cs diff --git a/RGB.NET.Core/Brushes/BrushCalculationMode.cs b/RGB.NET.Core/Brushes/BrushCalculationMode.cs new file mode 100644 index 0000000..3713d8f --- /dev/null +++ b/RGB.NET.Core/Brushes/BrushCalculationMode.cs @@ -0,0 +1,20 @@ +using RGB.NET.Core.Devices; + +namespace RGB.NET.Core.Brushes +{ + /// + /// Contains a list of all brush calculation modes. + /// + public enum BrushCalculationMode + { + /// + /// The calculation for will be the rectangle around the the is applied to. + /// + Relative, + + /// + /// The calculation for will always be the rectangle completly containing all affected . + /// + Absolute + } +} diff --git a/RGB.NET.Core/Brushes/BrushRenderTarget.cs b/RGB.NET.Core/Brushes/BrushRenderTarget.cs new file mode 100644 index 0000000..1ba4a1b --- /dev/null +++ b/RGB.NET.Core/Brushes/BrushRenderTarget.cs @@ -0,0 +1,47 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global + +namespace RGB.NET.Core.Brushes +{ + /// + /// Represents a single target of a brush render. + /// + public class BrushRenderTarget + { + #region Properties & Fields + + /// + /// Gets the target-. + /// + public Led Led { get; } + + /// + /// Gets the representing the area to render the target-. + /// + public Rectangle Rectangle { get; } + + /// + /// Gets the representing the position to render the target-. + /// + public Point Point { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The target-. + /// The representing the area to render the target-. + public BrushRenderTarget(Led led, Rectangle rectangle) + { + this.Led = led; + this.Rectangle = rectangle; + + this.Point = rectangle.Center; + } + + #endregion + } +} diff --git a/RGB.NET.Core/Brushes/IBrush.cs b/RGB.NET.Core/Brushes/IBrush.cs new file mode 100644 index 0000000..76de2e7 --- /dev/null +++ b/RGB.NET.Core/Brushes/IBrush.cs @@ -0,0 +1,58 @@ +// ReSharper disable UnusedMemberInSuper.Global +// ReSharper disable UnusedMember.Global +// ReSharper disable ReturnTypeCanBeEnumerable.Global + +using System.Collections.Generic; +using RGB.NET.Core.ColorCorrection; +using RGB.NET.Core.Effects; + +namespace RGB.NET.Core.Brushes +{ + /// + /// Represents a basic brush. + /// + public interface IBrush : IEffectTarget + { + /// + /// Gets or sets the calculation mode used for the rectangle/points used for color-selection in brushes. + /// + BrushCalculationMode BrushCalculationMode { get; set; } + + /// + /// Gets or sets the overall percentage brightness of the . + /// + float Brightness { get; set; } + + /// + /// Gets or sets the overall percentage opacity of the . + /// + float Opacity { get; set; } + + /// + /// Gets a list of used to correct the colors of the . + /// + IList ColorCorrections { get; } + + /// + /// Gets the used in the last render pass. + /// + Rectangle RenderedRectangle { get; } + + /// + /// Gets a dictionary containing all for calculated in the last render pass. + /// + Dictionary RenderedTargets { get; } + + /// + /// Performs the render pass of the and calculates the raw for all requested . + /// + /// The in which the brush should be drawn. + /// The (keys/points) of which the color should be calculated. + void PerformRender(Rectangle rectangle, IEnumerable renderTargets); + + /// + /// Performs the finalize pass of the and calculates the final for all previously calculated . + /// + void PerformFinalize(); + } +} \ No newline at end of file diff --git a/RGB.NET.Core/ColorCorrection/IColorCorrection.cs b/RGB.NET.Core/ColorCorrection/IColorCorrection.cs new file mode 100644 index 0000000..b0268d1 --- /dev/null +++ b/RGB.NET.Core/ColorCorrection/IColorCorrection.cs @@ -0,0 +1,14 @@ +namespace RGB.NET.Core.ColorCorrection +{ + /// + /// Represents a generic color-correction. + /// + public interface IColorCorrection + { + /// + /// Applies the to the given . + /// + /// The to correct. + void ApplyTo(Color color); + } +} diff --git a/RGB.NET.Core/Effects/IEffect.cs b/RGB.NET.Core/Effects/IEffect.cs new file mode 100644 index 0000000..8919425 --- /dev/null +++ b/RGB.NET.Core/Effects/IEffect.cs @@ -0,0 +1,64 @@ +// ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMemberInSuper.Global +// ReSharper disable UnusedParameter.Global + +using RGB.NET.Core.Devices; + +namespace RGB.NET.Core.Effects +{ + /// + /// Represents a basic effect. + /// + public interface IEffect + { + #region Properties & Fields + + /// + /// Gets if this has finished all of his work. + /// + bool IsDone { get; } + + #endregion + + #region Methods + + /// + /// Updates this . + /// + /// The elapsed time (in seconds) since the last update. + void Update(float deltaTime); + + #endregion + } + + /// + /// Represents a basic effect. + /// + /// The type of this effect can be attached to. + public interface IEffect : IEffect + where T : IEffectTarget + { + #region Methods + + /// + /// Checks if the can be applied to the target object. + /// + /// The this effect is attached to. + /// true if the can be attached; otherwise, false. + bool CanBeAppliedTo(T target); + + /// + /// Hook which is called when the is attached to a . + /// + /// The this effect is attached to. + void OnAttach(T target); + + /// + /// Hook which is called when the is detached from a . + /// + /// The this effect is detached from. + void OnDetach(T target); + + #endregion + } +} diff --git a/RGB.NET.Core/Effects/IEffectTarget.cs b/RGB.NET.Core/Effects/IEffectTarget.cs new file mode 100644 index 0000000..3866ee7 --- /dev/null +++ b/RGB.NET.Core/Effects/IEffectTarget.cs @@ -0,0 +1,33 @@ +// ReSharper disable UnusedMember.Global + +namespace RGB.NET.Core.Effects +{ + /// + /// Represents a basic effect-target. + /// + /// The type this target represents. + public interface IEffectTarget + where T : IEffectTarget + { + #region Methods + + /// + /// Updates all added to this target. + /// + void UpdateEffects(); + + /// + /// Adds an . + /// + /// The to add. + void AddEffect(IEffect effect); + + /// + /// Removes an . + /// + /// The to remove. + void RemoveEffect(IEffect effect); + + #endregion + } +} diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 7511fa3..d0c7cac 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -42,6 +42,12 @@ + + + + + +