Added Summeries

This commit is contained in:
Michel Fedde 2021-03-19 20:59:02 +01:00
parent 71a22df8bd
commit 8296d9b8a9
47 changed files with 812 additions and 177 deletions

View file

@ -14,14 +14,23 @@ using SM2D.Scene;
namespace SM2D.Drawing
{
/// <summary>
/// Allows easy access to draw something on the background.
/// </summary>
public class DrawBackground : DrawingBasis, IBackgroundItem
{
/// <summary>
/// Sets the color or tint (in case a texture is set).
/// </summary>
public Color4 Color
{
get => Material.Tint;
set => Material.Tint = value;
}
/// <summary>
/// Sets the texture of the background.
/// </summary>
public TextureBase Texture
{
get => Material.Texture;
@ -32,18 +41,34 @@ namespace SM2D.Drawing
}
}
/// <summary>
/// Creates a black background.
/// </summary>
public DrawBackground() : this(Color4.Black) {}
/// <summary>
/// Creates a background with a color.
/// </summary>
/// <param name="color"></param>
public DrawBackground(Color4 color)
{
Color = color;
}
/// <summary>
/// Creates a background with a texture.
/// </summary>
/// <param name="texture"></param>
public DrawBackground(Bitmap texture)
{
Texture = (Texture) texture;
}
/// <summary>
/// Creates a background with a texture and a tint.
/// </summary>
/// <param name="texture"></param>
/// <param name="tint"></param>
public DrawBackground(Bitmap texture, Color4 tint)
{
Color = tint;
@ -51,6 +76,7 @@ namespace SM2D.Drawing
}
/// <inheritdoc />
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);

View file

@ -10,46 +10,72 @@ using SM2D.Types;
namespace SM2D.Drawing
{
/// <inheritdoc />
public class DrawObject2D : DrawingBasis<Transformation>
{
/// <summary>
/// The texture the object should use.
/// </summary>
public Texture Texture
{
get => (Texture) Material.Texture;
set => Material.Texture = value;
}
/// <summary>
/// The color or tint the object should use.
/// </summary>
public Color4 Color
{
get => Material.Tint;
set => Material.Tint = value;
}
/// <inheritdoc />
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);
context.Shader.Draw(context);
}
public void SetShader(MaterialShader shader) => Material.CustomShader = shader;
public Polygon ApplyPolygon(ICollection<Vector2> vertices, bool centerUVs = false)
/// <summary>
/// Applies a polygon to the object.
/// </summary>
/// <param name="vertices"></param>
/// <returns></returns>
public Polygon ApplyPolygon(ICollection<Vector2> vertices)
{
Polygon polygon = new Polygon(vertices);
Mesh = polygon;
return polygon;
}
public Polygon ApplyPolygon(ICollection<PolygonVertex> vertices, bool centerUVs = false)
/// <summary>
/// Applies a polygon to the object.
/// </summary>
/// <param name="vertices"></param>
/// <returns></returns>
public Polygon ApplyPolygon(ICollection<PolygonVertex> vertices)
{
Polygon polygon = new Polygon(vertices);
Mesh = polygon;
return polygon;
}
/// <summary>
/// Applies a polygon to the object.
/// </summary>
public void ApplyPolygon(Polygon polygon)
{
Mesh = polygon;
}
public Polygon ApplyCircle(int segments = 32, bool centerUVs = false)
/// <summary>
/// This applies a circle.
/// </summary>
/// <param name="segments"></param>
/// <returns></returns>
public Polygon ApplyCircle(int segments = 32)
{
Polygon pol = Polygon.GenerateCircle(segments);
Mesh = pol;

View file

@ -6,14 +6,20 @@ using SM2D.Types;
namespace SM2D.Drawing
{
/// <summary>
/// Creates particles.
/// </summary>
public class DrawParticles : ParticleDrawingBasis<Transformation, Vector2>
{
/// <inheritdoc />
public override Func<Vector2, ParticleContext, Vector2> MovementCalculation { get; set; } = ParticleMovement.Default2D;
/// <inheritdoc />
public DrawParticles(TimeSpan duration) : base(duration)
{
}
/// <inheritdoc />
protected override ParticleStruct<Vector2> CreateObject(int index)
{
return new ParticleStruct<Vector2>()
@ -24,6 +30,7 @@ namespace SM2D.Drawing
};
}
/// <inheritdoc />
protected override Matrix4 CreateMatrix(ParticleStruct<Vector2> Struct, Vector2 direction)
{
return Struct.Matrix * Matrix4.CreateTranslation(direction.X, direction.Y, 0);

View file

@ -9,14 +9,21 @@ using SM2D.Types;
namespace SM2D.Drawing
{
/// <summary>
/// Draws a text to the world.
/// </summary>
public class DrawText : TextDrawingBasis<Transformation>
{
/// <summary>
/// Creates a text object.
/// </summary>
public DrawText(Font font, string text) : base(font)
{
_text = text;
Transform.Size = new CVector2(1);
}
/// <inheritdoc />
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);