Class HighlightBuilder
draw.npc(npc).color(Colors.RED).label(name).submit(); // tracks the NPC
draw.self().color(Colors.CYAN).untilCleared().submit();
draw.tile("flag", x, y, plane).filled().alpha(80).submit();
draw.area("zone", x, y, 5, 5, plane).label("safe").submit();
Why this is a separate type from DrawBuilder and
DrawCaptionBuilder. Two of the knobs those offer are meaningless
here, and this codebase's standing answer to a meaningless knob is to make it
unspellable rather than ignored — the same reason draw.rect(...).font(...)
does not compile:
- No
screen()/world(). There is no screen-space meaning for "the npc with index 42". The producer forcesworldon every highlight before it validates anything, so offering the choice would be offering one the caller does not have. - No
closed(). That is a polyline's flag and a highlight is never a polyline.
The geometry is not here either — which entity, which tile, how many tiles of
footprint, which plane — because each of those is specific to one of the four
calls and a wrong one has to be reportable by name. They are named parameters of
the DrawTarget method that opens the chain, so highlight_tile's
refusal of a w is a thing this API cannot express rather than a thing it
has to defend against.
The styling half is delegated to a DrawBuilder rather than copied, so
there is one implementation of what color or ttl mean across all
three chains. Only the return types differ, which is what keeps them typed.
-
Method Summary
Modifier and TypeMethodDescriptionalpha(int alpha) The current colour at a different 0..255 alpha.build()The highlight as configured, without sending it.caption()The caption as configured.color(int argb) Packed0xAARRGGBB.filled()Fill the marker rather than stroking it.filled(boolean fill) Fill or stroke explicitly.Draw the caption in a named style.Draw this text against the marker the producer resolved.submit()Send the highlight, and answer the key it is stored under — which is also how you clear it later.thickness(int pixels) Stroke width for the box drawn around the resolved marker.ttl(long milliseconds) Lifetime in milliseconds.Lifetime as aDuration, truncated to whole milliseconds.Keep this highlight until it is replaced, cleared, or the script's connection closes.value(long value) Caption with a whole number.value(long value, int decimals) Caption with a scaled number:value(1234, 2)renders"12.34".z(int order) Draw order; higher is drawn in front.
-
Method Details
-
label
Draw this text against the marker the producer resolved.The only way to tell two highlights apart, and it has to travel with the command precisely because the caller never learns where the marker landed. Replaces any caption already set — the wire allows exactly one per command, so these are alternatives rather than additions.
The producer spells it
label; sendingtextto a highlight is refused withentity names its caption "label", not "text". That spelling is chosen by the encoder from the command's own kind, so it is not a mistake reachable from here. -
value
Caption with a scaled number:value(1234, 2)renders"12.34". Replaces any caption already set.There is no float on this wire, deliberately. Send a scaled integer and say what you scaled it by; the producer does the formatting.
-
value
Caption with a whole number. -
font
Draw the caption in a named style. A style name, not a size — the producer owns the size table.Order-independent: the style is remembered and applied to whatever caption the chain ends up with, as well as to one already set. A font on a highlight that never gains a caption draws nothing and sends nothing, which is deliberately not an error — setting the style up front and the caption conditionally is a reasonable thing to write.
- Throws:
IllegalArgumentException- iffontis null
-
caption
The caption as configured. -
color
Packed0xAARRGGBB. SeeColors. -
alpha
The current colour at a different 0..255 alpha. -
thickness
Stroke width for the box drawn around the resolved marker. -
filled
Fill the marker rather than stroking it. -
filled
Fill or stroke explicitly. -
z
Draw order; higher is drawn in front. The only way to control which of several overlapping highlights is visible where they cross, which is exactly the case labels exist to serve. -
ttl
Lifetime in milliseconds. Defaults toDrawLimits.DEFAULT_TTL_MS. -
ttl
Lifetime as aDuration, truncated to whole milliseconds. -
untilCleared
Keep this highlight until it is replaced, cleared, or the script's connection closes. Not a way to leave something on screen after the script stops: ownership is connection-scoped and the producer drops everything a connection drew when its pipe closes. -
build
The highlight as configured, without sending it. -
submit
Send the highlight, and answer the key it is stored under — which is also how you clear it later.Off
Drawthis is onehighlight_*round-trip. Inside aDrawFrameit only queues; a highlight cannot ridedebug_draw_set_batch, so the frame sends it as its own call when it flushes. SeeDrawFrame.flush()for what that means for a frame that fails part-way.
-