Skip to content

Commit 1055358

Browse files
Copilotmikebarkmin
andcommitted
Add origin offset visualization in debug mode
Co-authored-by: mikebarkmin <[email protected]>
1 parent deee9a0 commit 1055358

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

  • src/main/java/org/openpatch/scratch/internal

src/main/java/org/openpatch/scratch/internal/Image.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,33 @@ public void drawDebug(
515515
double originY) {
516516
buffer.push();
517517
buffer.translate((float) x, (float) -y);
518-
buffer.fill(Window.DEBUG_COLOR[0], Window.DEBUG_COLOR[1], Window.DEBUG_COLOR[1]);
518+
buffer.fill(Window.DEBUG_COLOR[0], Window.DEBUG_COLOR[1], Window.DEBUG_COLOR[2]);
519519
buffer.textAlign(PConstants.CENTER);
520520
buffer.text("Direction: " + Math.round((degrees) * 100) / 100.0, 0, -this.height / 2.0f - 10);
521521
buffer.text("(" + Math.round(x * 100) / 100.0 + ", " + Math.round(y * 100) / 100.0 + ")", 0, 0);
522+
523+
// Draw origin marker and offset visualization
524+
if (originX != 0 || originY != 0) {
525+
// Draw text showing origin offset
526+
buffer.text(
527+
"Origin: (" + Math.round(originX * 100) / 100.0 + ", " + Math.round(originY * 100) / 100.0
528+
+ ")",
529+
0,
530+
this.height / 2.0f + 20);
531+
532+
// Draw a line from the sprite position to where the image center is drawn
533+
buffer.stroke(Window.DEBUG_COLOR[0], Window.DEBUG_COLOR[1], Window.DEBUG_COLOR[2]);
534+
buffer.strokeWeight(1);
535+
buffer.line(0, 0, (float) -originX, (float) originY);
536+
537+
// Draw a small cross at the origin point (sprite position)
538+
buffer.line(-5, 0, 5, 0);
539+
buffer.line(0, -5, 0, 5);
540+
541+
// Draw a small circle at the image center
542+
buffer.noFill();
543+
buffer.ellipse((float) -originX, (float) originY, 8, 8);
544+
}
522545
buffer.pop();
523546
}
524547

0 commit comments

Comments
 (0)