sim_chart ========= .. py:module:: sidequest_bot.lib.sim_chart .. autoapi-nested-parse:: Draws a gear sim's results as a PNG bar chart that reads at a glance: better to the right, worse to the left. Each :class:`Panel` is one gear option; inside it each :class:`MetricGroup` (threat, damage taken, DPS...) has one :class:`Bar` per fight. Bars are already oriented by the caller (positive = better for the player, so less damage taken points right) and coloured by :data:`Effect`, with grey for changes inside the sim's margin of error. Every option shares one scale, so bar lengths compare across options. Pillow's bundled font has no arrows or dashes, so all chart text must be plain ASCII. .. py:data:: Effect .. py:class:: Bar One fight's change: ``value`` is the % change oriented so positive is better; ``text`` is drawn beside it. .. py:attribute:: label :type: str .. py:attribute:: value :type: float .. py:attribute:: text :type: str .. py:attribute:: effect :type: Effect .. py:class:: MetricGroup One metric's bars, under a title like ``Threat``. .. py:attribute:: title :type: str .. py:attribute:: bars :type: list[Bar] .. py:class:: Panel One gear option: a title like ``Quel'Serrar vs Eater of the Dead`` and its metric groups. .. py:attribute:: title :type: str .. py:attribute:: groups :type: list[MetricGroup] .. py:data:: SCALE :value: 2 Drawn at twice the layout size so the chart stays sharp when Discord scales it down. .. py:data:: WIDTH :value: 640 .. py:data:: PAD :value: 20 .. py:data:: LABEL_WIDTH :value: 150 .. py:data:: TEXT_ROOM :value: 90 Room kept beside the longest bar for its value text. .. py:data:: BAR_HEIGHT :value: 18 .. py:data:: ROW_HEIGHT :value: 28 .. py:data:: GROUP_TITLE_HEIGHT :value: 26 .. py:data:: PANEL_TITLE_HEIGHT :value: 30 .. py:data:: AXIS_HEADER_HEIGHT :value: 22 .. py:data:: PANEL_GAP :value: 22 .. py:data:: MIN_SCALE_PCT :value: 2.0 The smallest full-bar scale, so a 0.3% change doesn't fill the chart and look huge. .. py:data:: MIN_BAR_WIDTH :value: 3 .. py:data:: BACKGROUND :value: (43, 45, 49) .. py:data:: TEXT :value: (242, 243, 245) .. py:data:: MUTED :value: (181, 186, 193) .. py:data:: AXIS :value: (90, 93, 102) .. py:data:: COLORS :type: dict[Effect, tuple[int, int, int]] .. py:function:: render_chart(panels: collections.abc.Sequence[Panel]) -> bytes ``panels`` drawn top to bottom as one PNG.