Skip to content

feat(sdk): Add coordinate origin option (center vs top-left) for DrawQuad/DrawSprite #554

Description

@aram-devdocs

Problem

The generated C# SDK's DrawQuad(x, y, w, h) and DrawSprite(x, y, w, h) use (x, y) as the center of the shape (confirmed in model_matrix — x/y are the translation in the transform matrix). This is undocumented and causes recurring hitbox mismatches when consumers assume top-left origin.

In Throne, we had to build a SceneUI helper that converts top-left coordinates to center coordinates before calling DrawQuad/DrawSprite. Every interactive element (buttons, hitboxes) was broken because the rendering position and hit-test position used different coordinate origins.

Request

  1. Document the current behavior clearly in the generated SDK docstrings — specify that (x, y) is the center of the quad/sprite, not top-left
  2. Add an optional CoordinateOrigin enum (Center, TopLeft) parameter or a global config so SDK consumers can choose their convention intentionally

Context

This affects all drawing APIs that take positional parameters:

  • DrawQuad(x, y, w, h, color)
  • DrawSprite(textureId, x, y, w, h)
  • DrawSpriteRect(textureId, x, y, w, h, ...)

DrawText appears to use top-left origin, which adds to the confusion since it differs from DrawQuad/DrawSprite.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions