-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from OpenSauce/Render-Debug-Depth
Added in Debug Rendering as a BFS to Render Depth
- Loading branch information
Showing
6 changed files
with
103 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
package furex | ||
|
||
var Debug = false | ||
import ( | ||
"image/color" | ||
|
||
"github.com/hajimehoshi/ebiten/v2" | ||
) | ||
|
||
var ( | ||
Debug = false | ||
debugColor = color.RGBA{0xff, 0, 0, 0xff} | ||
debugColorShift = ebiten.ColorM{} | ||
) | ||
|
||
func debugBorders(screen *ebiten.Image, root containerEmbed) { | ||
queue := []containerEmbed{} | ||
queue = append(queue, root) | ||
renderColor := resetDebugColor() | ||
|
||
for len(queue) > 0 { | ||
levelSize := len(queue) | ||
for levelSize != 0 { | ||
curr := queue[0] | ||
queue = queue[1:] | ||
|
||
G.DrawRect(screen, &DrawRectOpts{ | ||
Rect: curr.frame, | ||
Color: renderColor, | ||
StrokeWidth: 2, | ||
}) | ||
|
||
for _, c := range curr.children { | ||
queue = append(queue, c.item.containerEmbed) | ||
} | ||
levelSize-- | ||
} | ||
|
||
renderColor = rotateDebugColor() | ||
} | ||
} | ||
|
||
func rotateDebugColor() color.Color { | ||
debugColorShift.RotateHue(1.66) | ||
return debugColorShift.Apply(debugColor) | ||
} | ||
|
||
func resetDebugColor() color.Color { | ||
debugColorShift = ebiten.ColorM{} | ||
return debugColor | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.