Class CircleSprite

java.lang.Object
me.hackware.api.gui.CircleSprite

public final class CircleSprite extends Object
Smooth large-circle rendering. Big circles through the per-pixel fill helpers cost hundreds-to-thousands of quads per frame (and un-anti-aliased scanlines look stepped), so instead an anti-aliased disc+ring is baked once into a texture at exact physical resolution and drawn as a single 1:1 quad.

Textures are cached by (diameter, fill, ring) in a tiny LRU; a bake only happens when a new size/colour combination first appears (e.g. panel resize).

A bake walks every pixel of the sprite, and one the size of a macro wheel is 60 to 80 ms of it. Whoever knows ahead what it will draw says so with the prepare methods: the pixels are then made on a worker, and the draw that needs them only has to hand the finished image to the GPU. A sprite nobody prepared is still baked where it is drawn.

  • Method Details

    • draw

      public static void draw(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radius, int fill, int ring)
      Draws a filled circle with a ~1.5-physical-px ring, anti-aliased, centred at (cx, cy) in logical space. res is physical pixels per logical unit (see UiContext.res). Pass ring with zero alpha to skip the outline, or fill with zero alpha for ring-only.
    • drawPx

      public static void drawPx(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radiusPx, int fill, int ring)
      Like draw(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int) but with the radius in physical pixels (unscaled), for elements sized on a fixed dp baseline regardless of GUI/panel scale.
    • drawDonut

      public static void drawDonut(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radius, int innerRadius, int segments, int fill, int ring)
      Draws a donut (annulus) split into segments equal wedges by separator lines, with AA rings on both edges. innerRadius 0 makes a plain disc; segments 0 skips separators. Wedge 0 is centred at the top, matching
      invalid reference
      RadialMenu#segmentAt
      .
    • drawDonutSector

      public static void drawDonutSector(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radius, int innerRadius, int segments, int sector, int fill)
      Fills only wedge sector of a segmented donut — the selection highlight overlay for drawDonut(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int, int).
    • drawDonutSector

      public static void drawDonutSector(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radius, int innerRadius, int segments, int sector, int fill, int ring)
      Sector fill with an outline (ring) on its edges — the selected-slice highlight.
    • drawDonutSectorArcs

      public static void drawDonutSectorArcs(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radius, int innerRadius, int segments, int sector, int ring)
      Just the inner + outer arc borders of one wedge (ring), no radial separators.
    • drawDonutSectorRotated

      public static void drawDonutSectorRotated(net.minecraft.client.gui.GuiGraphics g, double res, int cx, int cy, int radius, int innerRadius, int segments, double rotationDeg, int fill, int ring, boolean arcsOnly)
      Draws wedge 0 of a segments donut rotated by rotationDeg about (cx, cy) — for a slice sitting at an arbitrary (animated) angle rather than a fixed slot. Pass arcsOnly for just the arc border. The radius is unchanged, so no per-angle re-bake.
    • prepareDonut

      public static void prepareDonut(double res, int radius, int innerRadius, int segments, int fill, int ring)
      Bakes the sprite drawDonut(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int, int) would draw with these arguments ahead of time, on a worker. Does nothing when it is cached or already on its way. Render thread.
    • prepareDonutSector

      public static void prepareDonutSector(double res, int radius, int innerRadius, int segments, int fill)
    • prepareDonutSectorArcs

      public static void prepareDonutSectorArcs(double res, int radius, int innerRadius, int segments, int ring)