bot_api.graphics package¶
Submodules¶
bot_api.graphics.color module¶
- class Color(_value: int)[source]¶
Bases:
objectRepresents an RGBA (red, green, blue, alpha) color used in the Tank Royale game.
This graphics Color implementation contains: - Internal 32-bit RGBA value - Factory methods from_rgb(), from_rgba(r,g,b,a), and from_rgba_value(rgba) - Read-only channel properties: red, green, blue, alpha (mapped to R,G,B,A) - to_rgba() for round-trip, to_hex_color() for hex string - Equality/hash based on RGBA value - Many predefined common colors
Note: For compatibility with existing Python code, to_color_schema() is preserved and uses lowercase hex values as before.
- classmethod from_rgba_value(rgba: int) Color[source]¶
Creates a color from a 32-bit RGBA value.
- Parameters:
rgba – A 32-bit value specifying the RGBA components.
- Returns:
A new Color initialized with the specified RGBA value.
- classmethod from_rgba(r: int, g: int, b: int, a: int) Color[source]¶
Creates a color from the specified red, green, blue, and alpha values.
- Parameters:
r – The red component value (0-255).
g – The green component value (0-255).
b – The blue component value (0-255).
a – The alpha component value (0-255).
- Returns:
A new Color initialized with the specified RGBA values.
- classmethod from_rgb(r: int, g: int, b: int) Color[source]¶
Creates a color from the specified red, green, and blue values with alpha 255 (fully opaque).
- Parameters:
r – The red component value (0-255).
g – The green component value (0-255).
b – The blue component value (0-255).
- Returns:
A new Color initialized with the specified RGB values and an alpha value of 255.
- classmethod from_color_with_alpha(base_color: Color, a: int) Color[source]¶
Creates a color from the specified base color with a new alpha value.
- Parameters:
base_color – The Color from which to derive the RGB values.
a – The alpha component value (0-255).
- Returns:
A new Color with the RGB values from the base color and the specified alpha value.
- classmethod from_hex_color(hex_color: str | None) Color | None[source]¶
Creates a color from a hex color string (#RGB, #RRGGBB, or #RRGGBBAA).
This method works the same as from_hex() except that it requires a hash sign before the hex value. An example of a numeric RGB value is “#09C” or “#0099CC”, which both represent the same color.
- Parameters:
hex_color – A string containing a hex color like “#09C”, “#0099CC”, or “#0099CCFF”.
- Returns:
A new Color; None if the input is None.
- Raises:
ValueError – If the string is not in valid numeric RGB format.
- classmethod from_hex(hex_triplet: str) Color[source]¶
Creates a color from a hex triplet (RGB, RRGGBB, or RRGGBBAA without hash).
A hex triplet is either three, six, or eight hexadecimal digits that represent an RGB or RGBA color. An example of a hex triplet is “09C” or “0099CC”, which both represent the same color.
- Parameters:
hex_triplet – A string containing hex digits like “09C”, “0099CC”, or “0099CCFF”.
- Returns:
A new Color.
- Raises:
ValueError – If the string is not valid hex digits (3, 6, or 8 characters).
- property red: int¶
Gets the red component value of this color.
- Returns:
The red component value between 0 and 255.
- property green: int¶
Gets the green component value of this color.
- Returns:
The green component value between 0 and 255.
- property blue: int¶
Gets the blue component value of this color.
- Returns:
The blue component value between 0 and 255.
- property alpha: int¶
Gets the alpha component value of this color.
- Returns:
The alpha component value between 0 and 255.
- property r: int¶
- property g: int¶
- property b: int¶
- property a: int¶
- to_rgba() int[source]¶
Converts this Color to a 32-bit RGBA value.
- Returns:
A 32-bit integer containing the RGBA representation of this color.
- to_hex_color() str[source]¶
Converts the color to its hexadecimal representation.
- Returns:
If alpha is 255 (fully opaque), returns “#RRGGBB”.
If alpha is not 255, returns “#RRGGBBAA”.
- Return type:
A string representing the color in hexadecimal format
- to_color_schema() Color[source]¶
Converts this color to the schema Color representation used by the API.
Note
The returned hex string uses lowercase letters for compatibility with the Python schema representation.
- Returns:
A Color schema object with the hex value set.
- ALICE_BLUE = Color(_value=4042850303)¶
- ANTIQUE_WHITE = Color(_value=4209760255)¶
- AQUA = Color(_value=16777215)¶
- AQUAMARINE = Color(_value=2147472639)¶
- AZURE = Color(_value=4043309055)¶
- BEIGE = Color(_value=4126530815)¶
- BISQUE = Color(_value=4293182719)¶
- BLACK = Color(_value=255)¶
- BLANCHED_ALMOND = Color(_value=4293643775)¶
- BLUE = Color(_value=65535)¶
- BLUE_VIOLET = Color(_value=2318131967)¶
- BROWN = Color(_value=2771004159)¶
- BURLY_WOOD = Color(_value=3736635391)¶
- CADET_BLUE = Color(_value=1604231423)¶
- CHARTREUSE = Color(_value=2147418367)¶
- CHOCOLATE = Color(_value=3530104575)¶
- CORAL = Color(_value=4286533887)¶
- CORNFLOWER_BLUE = Color(_value=1687547391)¶
- CORNSILK = Color(_value=4294499583)¶
- CRIMSON = Color(_value=3692313855)¶
- CYAN = Color(_value=16777215)¶
- DARK_BLUE = Color(_value=35839)¶
- DARK_CYAN = Color(_value=9145343)¶
- DARK_GOLDENROD = Color(_value=3095792639)¶
- DARK_GRAY = Color(_value=2846468607)¶
- DARK_GREEN = Color(_value=6553855)¶
- DARK_KHAKI = Color(_value=3182914559)¶
- DARK_MAGENTA = Color(_value=2332068863)¶
- DARK_OLIVE_GREEN = Color(_value=1433087999)¶
- DARK_ORANGE = Color(_value=4287365375)¶
- DARK_ORCHID = Color(_value=2570243327)¶
- DARK_RED = Color(_value=2332033279)¶
- DARK_SALMON = Color(_value=3918953215)¶
- DARK_SEA_GREEN = Color(_value=2411498495)¶
- DARK_SLATE_BLUE = Color(_value=1211993087)¶
- DARK_SLATE_GRAY = Color(_value=793726975)¶
- DARK_TURQUOISE = Color(_value=13554175)¶
- DARK_VIOLET = Color(_value=2483082239)¶
- DEEP_PINK = Color(_value=4279538687)¶
- DEEP_SKY_BLUE = Color(_value=12582911)¶
- DIM_GRAY = Color(_value=1768516095)¶
- DODGER_BLUE = Color(_value=512819199)¶
- FIREBRICK = Color(_value=2988581631)¶
- FLORAL_WHITE = Color(_value=4294635775)¶
- FOREST_GREEN = Color(_value=579543807)¶
- FUCHSIA = Color(_value=4278255615)¶
- GAINSBORO = Color(_value=3705462015)¶
- GHOST_WHITE = Color(_value=4177068031)¶
- GOLD = Color(_value=4292280575)¶
- GOLDENROD = Color(_value=3668254975)¶
- GRAY = Color(_value=2155905279)¶
- GREEN = Color(_value=8388863)¶
- GREEN_YELLOW = Color(_value=2919182335)¶
- HONEYDEW = Color(_value=4043305215)¶
- HOT_PINK = Color(_value=4285117695)¶
- INDIAN_RED = Color(_value=3445382399)¶
- INDIGO = Color(_value=1258324735)¶
- IVORY = Color(_value=4294963455)¶
- KHAKI = Color(_value=4041641215)¶
- LAVENDER = Color(_value=3873897215)¶
- LAVENDER_BLUSH = Color(_value=4293981695)¶
- LAWN_GREEN = Color(_value=2096890111)¶
- LEMON_CHIFFON = Color(_value=4294626815)¶
- LIGHT_BLUE = Color(_value=2916673279)¶
- LIGHT_CORAL = Color(_value=4034953471)¶
- LIGHT_CYAN = Color(_value=3774873599)¶
- LIGHT_GOLDENROD_YELLOW = Color(_value=4210742015)¶
- LIGHT_GRAY = Color(_value=3553874943)¶
- LIGHT_GREEN = Color(_value=2431553791)¶
- LIGHT_PINK = Color(_value=4290167295)¶
- LIGHT_SALMON = Color(_value=4288707327)¶
- LIGHT_SEA_GREEN = Color(_value=548580095)¶
- LIGHT_SKY_BLUE = Color(_value=2278488831)¶
- LIGHT_SLATE_GRAY = Color(_value=2005441023)¶
- LIGHT_STEEL_BLUE = Color(_value=2965692159)¶
- LIGHT_YELLOW = Color(_value=4294959359)¶
- LIME = Color(_value=16711935)¶
- LIME_GREEN = Color(_value=852308735)¶
- LINEN = Color(_value=4210091775)¶
- MAGENTA = Color(_value=4278255615)¶
- MAROON = Color(_value=2147483903)¶
- MEDIUM_AQUAMARINE = Color(_value=1724754687)¶
- MEDIUM_BLUE = Color(_value=52735)¶
- MEDIUM_ORCHID = Color(_value=3126187007)¶
- MEDIUM_PURPLE = Color(_value=2473647103)¶
- MEDIUM_SEA_GREEN = Color(_value=1018393087)¶
- MEDIUM_SLATE_BLUE = Color(_value=2070474495)¶
- MEDIUM_SPRING_GREEN = Color(_value=16423679)¶
- MEDIUM_TURQUOISE = Color(_value=1221709055)¶
- MEDIUM_VIOLET_RED = Color(_value=3340076543)¶
- MIDNIGHT_BLUE = Color(_value=421097727)¶
- MINT_CREAM = Color(_value=4127193855)¶
- MISTY_ROSE = Color(_value=4293190143)¶
- MOCCASIN = Color(_value=4293178879)¶
- NAVAJO_WHITE = Color(_value=4292783615)¶
- NAVY = Color(_value=33023)¶
- OLD_LACE = Color(_value=4260751103)¶
- OLIVE = Color(_value=2155872511)¶
- OLIVE_DRAB = Color(_value=1804477439)¶
- ORANGE = Color(_value=4289003775)¶
- ORANGE_RED = Color(_value=4282712319)¶
- ORCHID = Color(_value=3664828159)¶
- PALE_GOLDENROD = Color(_value=4008225535)¶
- PALE_GREEN = Color(_value=2566625535)¶
- PALE_TURQUOISE = Color(_value=2951671551)¶
- PALE_VIOLET_RED = Color(_value=3681588223)¶
- PAPAYA_WHIP = Color(_value=4293907967)¶
- PEACH_PUFF = Color(_value=4292524543)¶
- PERU = Color(_value=3448061951)¶
- PINK = Color(_value=4290825215)¶
- PLUM = Color(_value=3718307327)¶
- POWDER_BLUE = Color(_value=2967529215)¶
- PURPLE = Color(_value=2147516671)¶
- RED = Color(_value=4278190335)¶
- ROSY_BROWN = Color(_value=3163525119)¶
- ROYAL_BLUE = Color(_value=1097458175)¶
- SADDLE_BROWN = Color(_value=2336560127)¶
- SALMON = Color(_value=4202722047)¶
- SANDY_BROWN = Color(_value=4104413439)¶
- SEA_GREEN = Color(_value=780883967)¶
- SEA_SHELL = Color(_value=4294307583)¶
- SIENNA = Color(_value=2689740287)¶
- SILVER = Color(_value=3233857791)¶
- SKY_BLUE = Color(_value=2278484991)¶
- SLATE_BLUE = Color(_value=1784335871)¶
- SLATE_GRAY = Color(_value=1887473919)¶
- SNOW = Color(_value=4294638335)¶
- SPRING_GREEN = Color(_value=16744447)¶
- STEEL_BLUE = Color(_value=1182971135)¶
- TAN = Color(_value=3535047935)¶
- TEAL = Color(_value=8421631)¶
- THISTLE = Color(_value=3636451583)¶
- TOMATO = Color(_value=4284696575)¶
- TRANSPARENT = Color(_value=4294967040)¶
- TURQUOISE = Color(_value=1088475391)¶
- VIOLET = Color(_value=4001558271)¶
- WHEAT = Color(_value=4125012991)¶
- WHITE = Color(_value=4294967295)¶
- WHITE_SMOKE = Color(_value=4126537215)¶
- YELLOW = Color(_value=4294902015)¶
- YELLOW_GREEN = Color(_value=2597139199)¶
bot_api.graphics.graphics_abc module¶
- class GraphicsABC[source]¶
Bases:
ABCInterface for a graphics context that provides methods for drawing graphics primitives.
- abstractmethod draw_line(x1: float, y1: float, x2: float, y2: float) None[source]¶
Draws a line from point (x1, y1) to point (x2, y2).
- Parameters:
x1 – The x coordinate of the first point.
y1 – The y coordinate of the first point.
x2 – The x coordinate of the second point.
y2 – The y coordinate of the second point.
- abstractmethod draw_rectangle(x: float, y: float, width: float, height: float) None[source]¶
Draws the outline of a rectangle.
- Parameters:
x – The x coordinate of the upper-left corner of the rectangle.
y – The y coordinate of the upper-left corner of the rectangle.
width – The width of the rectangle.
height – The height of the rectangle.
- abstractmethod fill_rectangle(x: float, y: float, width: float, height: float) None[source]¶
Fills a rectangle with the current fill color.
- Parameters:
x – The x coordinate of the upper-left corner of the rectangle.
y – The y coordinate of the upper-left corner of the rectangle.
width – The width of the rectangle.
height – The height of the rectangle.
- abstractmethod draw_circle(x: float, y: float, radius: float) None[source]¶
Draws the outline of a circle.
- Parameters:
x – The x coordinate of the center of the circle.
y – The y coordinate of the center of the circle.
radius – The radius of the circle.
- abstractmethod fill_circle(x: float, y: float, radius: float) None[source]¶
Fills a circle with the current fill color.
- Parameters:
x – The x coordinate of the center of the circle.
y – The y coordinate of the center of the circle.
radius – The radius of the circle.
- abstractmethod draw_polygon(points: List[Point]) None[source]¶
Draws the outline of a polygon defined by a list of points.
- Parameters:
points – List of points defining the polygon.
- abstractmethod fill_polygon(points: List[Point]) None[source]¶
Fills a polygon defined by a list of points with the current fill color.
- Parameters:
points – List of points defining the polygon.
- abstractmethod draw_text(text: str, x: float, y: float) None[source]¶
Draws text at the specified position.
- Parameters:
text – The text to draw.
x – The x coordinate where to draw the text.
y – The y coordinate where to draw the text.
- abstractmethod set_stroke_color(color: Color) None[source]¶
Sets the color used for drawing outlines.
- Parameters:
color – The color to use for drawing outlines.
- abstractmethod set_fill_color(color: Color) None[source]¶
Sets the color used for filling shapes.
- Parameters:
color – The color to use for filling shapes.
- abstractmethod set_stroke_width(width: float) None[source]¶
Sets the width of the stroke used for drawing outlines.
- Parameters:
width – The width of the stroke.
- abstractmethod set_font(font_family: str, font_size: float) None[source]¶
Sets the font used for drawing text.
- Parameters:
font_family – The font family name.
font_size – The font size.
bot_api.graphics.point module¶
bot_api.graphics.svg_graphics module¶
- class SvgGraphicsABC[source]¶
Bases:
GraphicsABCImplementation of a graphics context that generates SVG markup.
This mirrors the Java SvgGraphics implementation and is intended to produce equivalent SVG output for the same drawing operations.
- draw_line(x1: float, y1: float, x2: float, y2: float) None[source]¶
Draws a line from point (x1, y1) to point (x2, y2).
- Parameters:
x1 – The x coordinate of the first point.
y1 – The y coordinate of the first point.
x2 – The x coordinate of the second point.
y2 – The y coordinate of the second point.
- draw_rectangle(x: float, y: float, width: float, height: float) None[source]¶
Draws the outline of a rectangle.
- Parameters:
x – The x coordinate of the upper-left corner of the rectangle.
y – The y coordinate of the upper-left corner of the rectangle.
width – The width of the rectangle.
height – The height of the rectangle.
- fill_rectangle(x: float, y: float, width: float, height: float) None[source]¶
Fills a rectangle with the current fill color.
- Parameters:
x – The x coordinate of the upper-left corner of the rectangle.
y – The y coordinate of the upper-left corner of the rectangle.
width – The width of the rectangle.
height – The height of the rectangle.
- draw_circle(x: float, y: float, radius: float) None[source]¶
Draws the outline of a circle.
- Parameters:
x – The x coordinate of the center of the circle.
y – The y coordinate of the center of the circle.
radius – The radius of the circle.
- fill_circle(x: float, y: float, radius: float) None[source]¶
Fills a circle with the current fill color.
- Parameters:
x – The x coordinate of the center of the circle.
y – The y coordinate of the center of the circle.
radius – The radius of the circle.
- draw_polygon(points: List[Point]) None[source]¶
Draws the outline of a polygon defined by a list of points.
- Parameters:
points – List of points defining the polygon.
- fill_polygon(points: List[Point]) None[source]¶
Fills a polygon defined by a list of points with the current fill color.
- Parameters:
points – List of points defining the polygon.
- draw_text(text: str, x: float, y: float) None[source]¶
Draws text at the specified position.
- Parameters:
text – The text to draw.
x – The x coordinate where to draw the text.
y – The y coordinate where to draw the text.
- set_stroke_color(color: Color) None[source]¶
Sets the color used for drawing outlines.
- Parameters:
color – The color to use for drawing outlines.
- set_fill_color(color: Color) None[source]¶
Sets the color used for filling shapes.
- Parameters:
color – The color to use for filling shapes.
- set_stroke_width(width: float) None[source]¶
Sets the width of the stroke used for drawing outlines.
- Parameters:
width – The width of the stroke.
- set_font(font_family: str, font_size: float) None[source]¶
Sets the font used for drawing text.
- Parameters:
font_family – The font family name.
font_size – The font size.