Sprite BlendMode Property Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D
Assembly: DeltaEngine.Rendering2D (in DeltaEngine.Rendering2D.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public BlendMode BlendMode { get; set; }

Property Value

Type: BlendMode
Remarks

Tests: DeltaEngine.Rendering2D.Tests.SpriteSaveAndLoadTests
Examples

5 unit tests call DeltaEngine.Rendering2D.Sprite.BlendMode
[Test, CloseAfterFirstFrame]
public void CreateSpriteFromComponents()
{
    var components = new List<object>();
    components.Add(Rectangle.One);
    components.Add(true);
    var material = new Material(ShaderFlags.Position2DTextured, "DeltaEngineLogo");
    components.Add(material);
    components.Add(material.DiffuseMap.BlendMode);
    components.Add(new RenderingData());
    var sprite = Activator.CreateInstance(typeof(Sprite),
        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder,
        null, CultureInfo.CurrentCulture) as Sprite;
    sprite.SetComponents(components);
    Assert.AreEqual(material, sprite.Material);
    Assert.AreEqual(Rectangle.One, sprite.DrawArea);
    Assert.AreEqual(material.DiffuseMap.BlendMode, sprite.BlendMode);
}
[Test, CloseAfterFirstFrame]
public void SaveAndLoadSprite()
{
    var sprite = new Sprite("DeltaEngineLogo", Rectangle.One);
    var data = BinaryDataExtensions.SaveToMemoryStream(sprite);
    Assert.Greater(data.Length, 0);
    var loadedSprite = data.CreateFromMemoryStream() as Sprite;
    Assert.AreEqual(sprite.Material.Shader, loadedSprite.Material.Shader);
    Assert.AreEqual(sprite.Material.DiffuseMap, loadedSprite.Material.DiffuseMap);
    Assert.AreEqual(sprite.DrawArea, loadedSprite.DrawArea);
    Assert.AreEqual(sprite.BlendMode, loadedSprite.BlendMode);
    Assert.AreEqual(sprite.Rotation, loadedSprite.Rotation);
    Assert.AreEqual(1, loadedSprite.GetActiveBehaviors().Count);
    Assert.AreEqual(1, loadedSprite.GetDrawBehaviors().Count);
    Assert.AreEqual("SpriteRenderer",
        loadedSprite.GetDrawBehaviors()[0].GetShortNameOrFullNameIfNotFound());
}
[Test, CloseAfterFirstFrame]
public void ChangingMaterialChangesImageAndBlendMode()
{
    var sprite = new Sprite(logoMaterial, Rectangle.HalfCentered);
    Assert.AreEqual("DeltaEngineLogoAlpha", sprite.Material.DiffuseMap.Name);
    Assert.AreEqual(BlendMode.Normal, sprite.BlendMode);
    var material = new Material(ShaderFlags.Position2DTextured, "Verdana12Font");
    material.DiffuseMap.BlendMode = BlendMode.Opaque;
    sprite.Material = material;
    Assert.AreEqual("Verdana12Font", sprite.Material.DiffuseMap.Name);
    Assert.AreEqual(BlendMode.Opaque, sprite.BlendMode);
}
See Also