+ Texture.Aspect
+ Transformation.ApplyTextureSize(Texture texture) & Transformation.ApplyTextureSize(Texture texture, float width)
This commit is contained in:
parent
1a0148ff90
commit
57fb71d01b
4 changed files with 34 additions and 4 deletions
|
|
@ -25,6 +25,22 @@ namespace SM.Base.Textures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Bitmap Map;
|
public Bitmap Map;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override int Width
|
||||||
|
{
|
||||||
|
get => Map.Width;
|
||||||
|
protected set
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override int Height
|
||||||
|
{
|
||||||
|
get => Map.Height;
|
||||||
|
protected set {}
|
||||||
|
}
|
||||||
|
public float Aspect { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Empty constructor
|
/// Empty constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -50,6 +66,9 @@ namespace SM.Base.Textures
|
||||||
public Texture(Bitmap map, TextureMinFilter filter, TextureWrapMode wrapMode)
|
public Texture(Bitmap map, TextureMinFilter filter, TextureWrapMode wrapMode)
|
||||||
{
|
{
|
||||||
Map = map;
|
Map = map;
|
||||||
|
|
||||||
|
Aspect = (float)map.Width / map.Height;
|
||||||
|
|
||||||
Filter = filter;
|
Filter = filter;
|
||||||
WrapMode = wrapMode;
|
WrapMode = wrapMode;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ namespace SM.OGL.Texture
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Width of the texture
|
/// The Width of the texture
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Width { get; protected set; }
|
public virtual int Width { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The height of the texture
|
/// The height of the texture
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Height { get; protected set; }
|
public virtual int Height { get; protected set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
#region usings
|
#region usings
|
||||||
|
|
||||||
|
using System;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using SM.Base.Drawing;
|
using SM.Base.Drawing;
|
||||||
using SM.Base.Scene;
|
using SM.Base.Scene;
|
||||||
|
using SM.Base.Textures;
|
||||||
using SM.Base.Types;
|
using SM.Base.Types;
|
||||||
using SM.Utility;
|
using SM.Utility;
|
||||||
|
|
||||||
|
|
@ -38,5 +40,15 @@ namespace SM2D.Types
|
||||||
vec.Normalize();
|
vec.Normalize();
|
||||||
return vec.Xy;
|
return vec.Xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ApplyTextureSize(Texture texture)
|
||||||
|
{
|
||||||
|
Size.Set(texture.Width, texture.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyTextureSize(Texture texture, float width)
|
||||||
|
{
|
||||||
|
Size.Set(width, width / texture.Aspect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,9 +55,8 @@ namespace SM_TEST
|
||||||
scene.ShowAxisHelper = true;
|
scene.ShowAxisHelper = true;
|
||||||
|
|
||||||
DrawObject2D kasten = new DrawObject2D();
|
DrawObject2D kasten = new DrawObject2D();
|
||||||
kasten.Transform.Size.Set(500,500);
|
|
||||||
kasten.ApplyCircle();
|
|
||||||
kasten.Texture = new Texture(new Bitmap("herosword.png"));
|
kasten.Texture = new Texture(new Bitmap("herosword.png"));
|
||||||
|
kasten.Transform.ApplyTextureSize(kasten.Texture, 500);
|
||||||
scene.Objects.Add(kasten);
|
scene.Objects.Add(kasten);
|
||||||
|
|
||||||
//particles.Trigger();
|
//particles.Trigger();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue