* @brief Release every resource owned by the plot. * * Iterates each series and frees its xData / yData / label buffers, * then frees the title and axis-label strings, and finally the Plot * struct itself. After this call the pointer @p plot is invalid and * must not be reused. * * This function is the only correct way to dispose of a Plot returned * by plot_create(); using `free()` direct
| 356 | |
| 357 | for (size_t s = 0; s < plot->seriesCount; ++s) { |
| 358 | DrawRectangle(lx + 10, ly + 10 + 30 * (int)s, 20, 20, plotcolor_to_raylib(plot->series[s].color)); |
| 359 | DrawText(plot->series[s].label ? plot->series[s].label : "(series)", lx + 40, ly + 10 + 30 * (int)s, 18, plotcolor_to_raylib(plot->legendTextColor)); |
| 360 | } |
| 361 | DrawRectangleLines(lx, ly, legendW, legendH, plotcolor_to_raylib(plot->axisColor)); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | |
| 366 | /** |
| 367 | * @brief Create a new plot configured with default colours and sizes. |
| 368 | * |
| 369 | * Allocates a zero-initialized Plot via `calloc` and populates it with |
| 370 | * sane defaults so it can be drawn immediately even before any series |
| 371 | * is attached: |
| 372 | * - title / xLabel / yLabel are deep-copied (NULL becomes the literal |
| 373 | * "Untitled Plot" / "X Axis" / "Y Axis"), |
| 374 | * - the canvas size is 800x600 pixels, |
| 375 | * - the legend and grid are both visible, |
| 376 | * - the colour palette matches the built-in light theme (white |
| 377 | * background, black axes, soft grey grid, off-white legend). |
| 378 | * |
| 379 | * Ownership semantics: the returned Plot owns every string it stores; |
| 380 | * the caller may free its own copies of @p title / @p xLabel / @p yLabel |