AURA

JSGG

AuraJS
DOCSEXAMPLESGITHUB
03 Draw2D, Sprites, Text, and Transforms
Immediate-mode 2D drawing, sprites, text, transforms, and batching caveats.
docs/external/game-dev-api/03-draw2d-sprites-text-and-transforms.md

Draw2D, Sprites, Text, and Transforms

aura.draw2d is the core immediate-mode 2D rendering namespace.

Core drawing methods

Primitives:

  • clear(colorOrR, g?, b?, a?)
  • rect(x, y, width, height, color)
  • rectFill(x, y, width, height, color)
  • circle(x, y, radius, color)
  • circleFill(x, y, radius, color)
  • line(x1, y1, x2, y2, color, width?)
  • polygon(points, color)
  • polygonFill(points, color)
  • polyline(points, color, width?)
  • bezier(...)
  • quadratic(...)
  • arc(...)
  • arcFill(...)
  • triangle(...)
  • triangleFill(...)
  • ellipse(...)
  • ellipseFill(...)
  • roundedRect(...)
  • roundedRectFill(...)

State helpers:

  • setBlendMode(mode)
  • setFill(fillSpec)
  • clearFill()

Sprites and images

Primary sprite method:

  • sprite(source, x, y, options?)

Legacy alias still available:

  • image(source, x, y, options?)

Common sprite options:

  • width, height
  • frameX, frameY, frameW, frameH
  • scaleX, scaleY
  • rotation
  • originX, originY
  • tint
  • alpha
  • flipX, flipY

Use cases:

  • atlas-frame rendering
  • billboard-style 2D objects
  • sprite transforms without maintaining your own matrix stack

Text

Text methods:

  • text(content, x, y, optionsOrColor?)
  • styledText(segments, x, y, options?)
  • measureText(content, options?)

Common text options:

  • size
  • align
  • color
  • font
  • shadow
  • outline

styledText(...) supports segment-level styling using the same general option shape.

Transform stack

Transform helpers:

  • pushTransform()
  • popTransform()
  • translate(x, y)
  • rotate(radians)
  • scale(x, y?)

Legacy aliases:

  • push()
  • pop()

Use cases:

  • hierarchical HUD/layout transforms
  • rotating weapons/projectiles
  • temporary zoom/offset stacks

Typical aura.draw() flow:

  1. clear the frame
  2. set any transient draw state
  3. push transforms if needed
  4. issue immediate draw calls
  5. pop transforms before exiting

Color inputs

The drawing APIs accept the canonical color helpers documented in 06 Math, Colors, Vectors, Timers, Collision, and ECS:

  • aura.rgb(...)
  • aura.rgba(...)
  • aura.Color.*

Legacy color aliases also exist for compatibility, but new code should stick to the canonical forms above.

DOCUMENT REFERENCE
docs/external/game-dev-api/03-draw2d-sprites-text-and-transforms.md
AURAJS
Cmd/Ctrl+K
aurajsgg