1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Added more basic stuff

This commit is contained in:
Darth Affe 2017-01-21 23:25:24 +01:00
parent 87e4016381
commit 4e001d1087
7 changed files with 242 additions and 0 deletions

View File

@ -0,0 +1,20 @@
using RGB.NET.Core.Devices;
namespace RGB.NET.Core.Brushes
{
/// <summary>
/// Contains a list of all brush calculation modes.
/// </summary>
public enum BrushCalculationMode
{
/// <summary>
/// The calculation <see cref="Rectangle"/> for <see cref="IBrush"/> will be the rectangle around the <see cref="ILedGroup"/> the <see cref="IBrush"/> is applied to.
/// </summary>
Relative,
/// <summary>
/// The calculation <see cref="Rectangle"/> for <see cref="IBrush"/> will always be the rectangle completly containing all affected <see cref="IRGBDevice"/>.
/// </summary>
Absolute
}
}

View File

@ -0,0 +1,47 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
namespace RGB.NET.Core.Brushes
{
/// <summary>
/// Represents a single target of a brush render.
/// </summary>
public class BrushRenderTarget
{
#region Properties & Fields
/// <summary>
/// Gets the target-<see cref="Core.Led"/>.
/// </summary>
public Led Led { get; }
/// <summary>
/// Gets the <see cref="Core.Rectangle"/> representing the area to render the target-<see cref="Core.Led"/>.
/// </summary>
public Rectangle Rectangle { get; }
/// <summary>
/// Gets the <see cref="Core.Point"/> representing the position to render the target-<see cref="Core.Led"/>.
/// </summary>
public Point Point { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="BrushRenderTarget"/> class.
/// </summary>
/// <param name="led">The target-<see cref="Core.Led"/>.</param>
/// <param name="rectangle">The <see cref="Core.Rectangle"/> representing the area to render the target-<see cref="Core.Led"/>.</param>
public BrushRenderTarget(Led led, Rectangle rectangle)
{
this.Led = led;
this.Rectangle = rectangle;
this.Point = rectangle.Center;
}
#endregion
}
}

View File

@ -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
{
/// <summary>
/// Represents a basic brush.
/// </summary>
public interface IBrush : IEffectTarget<IBrush>
{
/// <summary>
/// Gets or sets the calculation mode used for the rectangle/points used for color-selection in brushes.
/// </summary>
BrushCalculationMode BrushCalculationMode { get; set; }
/// <summary>
/// Gets or sets the overall percentage brightness of the <see cref="IBrush"/>.
/// </summary>
float Brightness { get; set; }
/// <summary>
/// Gets or sets the overall percentage opacity of the <see cref="IBrush"/>.
/// </summary>
float Opacity { get; set; }
/// <summary>
/// Gets a list of <see cref="IColorCorrection"/> used to correct the colors of the <see cref="IBrush"/>.
/// </summary>
IList<IColorCorrection> ColorCorrections { get; }
/// <summary>
/// Gets the <see cref="RenderedRectangle"/> used in the last render pass.
/// </summary>
Rectangle RenderedRectangle { get; }
/// <summary>
/// Gets a dictionary containing all <see cref="Color"/> for <see cref="BrushRenderTarget"/> calculated in the last render pass.
/// </summary>
Dictionary<BrushRenderTarget, Color> RenderedTargets { get; }
/// <summary>
/// Performs the render pass of the <see cref="IBrush"/> and calculates the raw <see cref="Color"/> for all requested <see cref="BrushRenderTarget"/>.
/// </summary>
/// <param name="rectangle">The <see cref="Rectangle"/> in which the brush should be drawn.</param>
/// <param name="renderTargets">The <see cref="BrushRenderTarget"/> (keys/points) of which the color should be calculated.</param>
void PerformRender(Rectangle rectangle, IEnumerable<BrushRenderTarget> renderTargets);
/// <summary>
/// Performs the finalize pass of the <see cref="IBrush"/> and calculates the final <see cref="ColorCorrections"/> for all previously calculated <see cref="BrushRenderTarget"/>.
/// </summary>
void PerformFinalize();
}
}

View File

@ -0,0 +1,14 @@
namespace RGB.NET.Core.ColorCorrection
{
/// <summary>
/// Represents a generic color-correction.
/// </summary>
public interface IColorCorrection
{
/// <summary>
/// Applies the <see cref="IColorCorrection"/> to the given <see cref="Color"/>.
/// </summary>
/// <param name="color">The <see cref="Color"/> to correct.</param>
void ApplyTo(Color color);
}
}

View File

@ -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
{
/// <summary>
/// Represents a basic effect.
/// </summary>
public interface IEffect
{
#region Properties & Fields
/// <summary>
/// Gets if this <see cref="IEffect"/> has finished all of his work.
/// </summary>
bool IsDone { get; }
#endregion
#region Methods
/// <summary>
/// Updates this <see cref="IEffect"/>.
/// </summary>
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
void Update(float deltaTime);
#endregion
}
/// <summary>
/// Represents a basic effect.
/// </summary>
/// <typeparam name="T">The type of <see cref="IEffectTarget{T}"/> this effect can be attached to.</typeparam>
public interface IEffect<in T> : IEffect
where T : IEffectTarget<T>
{
#region Methods
/// <summary>
/// Checks if the <see cref="IEffect{T}"/> can be applied to the target object.
/// </summary>
/// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is attached to.</param>
/// <returns><c>true</c> if the <see cref="IEffectTarget{T}"/> can be attached; otherwise, <c>false</c>.</returns>
bool CanBeAppliedTo(T target);
/// <summary>
/// Hook which is called when the <see cref="IEffect{T}"/> is attached to a <see cref="IRGBDevice"/>.
/// </summary>
/// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is attached to.</param>
void OnAttach(T target);
/// <summary>
/// Hook which is called when the <see cref="IEffect{T}"/> is detached from a <see cref="IRGBDevice"/>.
/// </summary>
/// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is detached from.</param>
void OnDetach(T target);
#endregion
}
}

View File

@ -0,0 +1,33 @@
// ReSharper disable UnusedMember.Global
namespace RGB.NET.Core.Effects
{
/// <summary>
/// Represents a basic effect-target.
/// </summary>
/// <typeparam name="T">The type this target represents.</typeparam>
public interface IEffectTarget<out T>
where T : IEffectTarget<T>
{
#region Methods
/// <summary>
/// Updates all <see cref="IEffect{T}"/> added to this target.
/// </summary>
void UpdateEffects();
/// <summary>
/// Adds an <see cref="IEffect{T}"/>.
/// </summary>
/// <param name="effect">The <see cref="IEffect{T}"/> to add.</param>
void AddEffect(IEffect<T> effect);
/// <summary>
/// Removes an <see cref="IEffect{T}"/>.
/// </summary>
/// <param name="effect">The <see cref="IEffect{T}"/> to remove.</param>
void RemoveEffect(IEffect<T> effect);
#endregion
}
}

View File

@ -42,6 +42,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Brushes\BrushCalculationMode.cs" />
<Compile Include="Brushes\BrushRenderTarget.cs" />
<Compile Include="Brushes\IBrush.cs" />
<Compile Include="ColorCorrection\IColorCorrection.cs" />
<Compile Include="Effects\IEffect.cs" />
<Compile Include="Effects\IEffectTarget.cs" />
<Compile Include="ILedId.cs" />
<Compile Include="MVVM\AbstractBindable.cs" />
<Compile Include="Color.cs" />