Image & Canvas
canvasProgressBar
$canvasProgressBar[]
Draws a progress bar (horizontal or vertical) with a track, a fill, a centered percentage label and an optional border
Syntax
$canvasProgressBar[x;y;width;height;percentage;barColor;trackColor;(textColor);(borderWidth);(orientation);(fontSize);(container);(borderRadius)]
Parameters
The bar is drawn on the current canvas (the last one made with $canvasCreate). The first 7 parameters are required; the 6 following ones are optional (13 at most).
| Parameter | Description |
|---|---|
x, y |
Position of the bar. |
width, height |
Size of the bar (defaults to 100 and 20 if the value is not a number). |
percentage |
Fill percentage, an integer between 0 and 100 (clamped to this range; 0 if not a number). |
barColor |
Color of the filled part (and of the border). |
trackColor |
Color of the full bar area behind the fill. Required. |
textColor |
Optional. Color of the percentage label. White when empty. |
borderWidth |
Optional. Border thickness (0 to 50, default 0). The border is drawn in barColor; there is no separate border color. |
orientation |
Optional. vertical for a vertical bar; any other value gives a horizontal bar. |
fontSize |
Optional. Font size of the percentage label (default 14). Only three bitmap sizes exist: below 20, 20 to 39, and 40 and above. |
container |
Optional. Name of a container defined earlier with $canvasContainer; x/y are offset by the container’s position. May be left empty to set borderRadius. |
borderRadius |
Optional. Corner radius (0 to 500, default 0). Rounded corners are rendered. |
A label showing the percentage (e.g. 75%) is drawn at the center of the bar. Horizontal bars fill left-to-right; vertical bars fill bottom-to-top.
Examples
Render Level XP Progress Bar
$canvasCreate[levelCard;600;140;#181818]
$canvasDrawText[Level 15 - 75% XP;30;45;20;#FFFFFF]
$canvasProgressBar[30;70;540;26;75;#5865F2;#2F3136;#FFFFFF;3;horizontal;14;;10]
$attachImage[levelCard]
$sendMessage[Rendered dynamic XP progress bar.]
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.