Skip to content

Commit f8b5c62

Browse files
authored
Merge pull request #404 from Gohan/master
walkaround for Monogame Widgets Drawlines not from center origin.
2 parents b238d75 + f2898df commit f8b5c62

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Myra/Graphics2D/RenderContext.Shapes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void DrawLine(Vector2 point, float length, float angle, Color color,
181181
float thickness = 1f)
182182
{
183183
var scale = new Vector2(length, thickness);
184-
Draw(DefaultAssets.WhiteTexture, point, null, color, angle, scale, 0);
184+
Draw(DefaultAssets.WhiteTexture, point, null, color, angle, scale, 0, drawLine: true);
185185
}
186186

187187
/// <summary>

src/Myra/Graphics2D/RenderContext.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? s
245245
/// <param name="color"></param>
246246
/// <param name="rotation"></param>
247247
/// <param name="depth"></param>
248-
public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 scale, float depth = 0.0f)
248+
public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 scale, float depth = 0.0f, bool drawLine = false)
249249
{
250250
SetTextureFiltering(TextureFiltering.Nearest);
251251
color = CrossEngineStuff.MultiplyColor(color, Opacity);
@@ -254,7 +254,8 @@ public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle
254254

255255
#if MONOGAME || FNA
256256
position = Transform.Apply(position);
257-
_renderer.Draw(texture, position, sourceRectangle, color, rotation, Vector2.Zero, scale, SpriteEffects.None, depth);
257+
_renderer.Draw(texture, position, sourceRectangle, color, rotation,
258+
drawLine ? new Vector2(0f, 0.5f) : Vector2.Zero, scale, SpriteEffects.None, depth);
258259
#elif STRIDE
259260
position = Transform.Apply(position);
260261
_renderer.Draw(texture, position, sourceRectangle, color, rotation, Vector2.Zero, scale, SpriteEffects.None, ImageOrientation.AsIs, depth);

0 commit comments

Comments
 (0)