Skip to content

Commit

Permalink
draw bounding box in one shape
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Jun 13, 2024
1 parent cad7993 commit 2e5577d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions flixel/system/debug/FlxDebugDrawGraphic.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ abstract FlxDebugDrawGraphic(Graphics) from Graphics to Graphics
{
inline function useFill()
{
return #if mac false #else FlxG.renderTile #end;
// true for testing
return true;
//return #if (cpp || hl) false #else FlxG.renderTile #end;
}

public function drawBoundingBox(x:Float, y:Float, width:Float, height:Float, color:FlxColor, thickness = 1.0)
Expand All @@ -18,10 +20,18 @@ abstract FlxDebugDrawGraphic(Graphics) from Graphics to Graphics
{
this.beginFill(color.rgb, color.alphaFloat);

this.drawRect(x, y, thickness, height);
this.drawRect(x + thickness, y, width - 2 * thickness, thickness);
this.drawRect(x + width - thickness, y, thickness, height);
this.drawRect(x + thickness, y + height - thickness, width - 2 * thickness, thickness);
// outer
this.moveTo(x, y);
this.lineTo(x + width, y);
this.lineTo(x + width, y + height);
this.lineTo(x, y + height);
this.lineTo(x, y);
// inner
this.lineTo(x + thickness, y + thickness);
this.lineTo(x + thickness, y + height - thickness);
this.lineTo(x + width - thickness, y + height - thickness);
this.lineTo(x + width - thickness, y + thickness);
this.lineTo(x + thickness, y + thickness);

this.endFill();
}
Expand Down

0 comments on commit 2e5577d

Please sign in to comment.