From 04e186d945c424ba1b6adf85fab6e1c3cee6f159 Mon Sep 17 00:00:00 2001 From: ezequias2d Date: Wed, 24 Nov 2021 17:20:13 -0300 Subject: [PATCH] Bugfix: location not working in source rectangle. --- src/Peridot.Demo/Program.cs | 2 +- src/Peridot/BatchItem.cs | 2 +- src/build/common.props.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Peridot.Demo/Program.cs b/src/Peridot.Demo/Program.cs index 17c4f7f..679eb68 100644 --- a/src/Peridot.Demo/Program.cs +++ b/src/Peridot.Demo/Program.cs @@ -63,7 +63,7 @@ var size = new Vector2(texture.Width, texture.Height); var pos = size * -0.5f; - var source = new System.Drawing.Rectangle(0, 0, (int)texture.Width / 2, (int)texture.Height / 2); + var source = new System.Drawing.Rectangle((int)texture.Width / 2, (int)texture.Height / 2, (int)texture.Width / 2, (int)texture.Height / 2); sb.Draw(texture, default, source, Color.White, 0, new(-size.X / 6, 0), Vector2.One, 1f); tr.DrawString(font, 32, "Hello World!", new Vector2(1, 1), Color.White, 0, new Vector2(0, 0), new Vector2(1), 0f); diff --git a/src/Peridot/BatchItem.cs b/src/Peridot/BatchItem.cs index aea23ba..aceb467 100644 --- a/src/Peridot/BatchItem.cs +++ b/src/Peridot/BatchItem.cs @@ -43,7 +43,7 @@ public BatchItem(Vector2 textureSize, float layerDepth) { var sourceSize = new Vector2(sourceRectangle.Width, sourceRectangle.Height) / textureSize; - var pos = new Vector2(sourceRectangle.X, sourceRectangle.Y); + var pos = new Vector2(sourceRectangle.X, sourceRectangle.Y) / textureSize; UV = Matrix4x4.CreateScale(new Vector3(sourceSize, 1)) * Matrix4x4.CreateTranslation(new(pos, 0)); Color = ToVector(color); diff --git a/src/build/common.props.csproj b/src/build/common.props.csproj index d1c38bf..51092e5 100644 --- a/src/build/common.props.csproj +++ b/src/build/common.props.csproj @@ -4,7 +4,7 @@ LICENSE https://github.com/ezequias2d/peridot ezequias2d and Peridot contributors. - 0.2.1-alpha + 0.2.2-alpha true ..\build\nupkgs peridot.png