Код: Выделить всё
#include
#define NANOSVG_IMPLEMENTATION
#include "nanosvg.h"
#include
#include
// Store the bounding box
struct BBox {
float minX = 1e10f, minY = 1e10f;
float maxX = -1e10f, maxY = -1e10f;
void update(float x, float y) {
if (x < minX) minX = x;
if (y < minY) minY = y;
if (x > maxX) maxX = x;
if (y > maxY) maxY = y;
}
};
BBox compute_bbox(NSVGimage* image) {
BBox box;
for (NSVGshape* shape = image->shapes; shape != NULL; shape = shape->next) {
for (NSVGpath* path = shape->paths; path != NULL; path = path->next) {
for (int i = 0; i < path->npts - 1; i += 3) {
float* p = &path->pts[i * 2];
box.update(p[0], p[1]);
}
}
}
return box;
}
void draw_svg(NSVGimage* image) {
if (!image) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79690510/latex-svg-file-wrongly-displaying-in-c-with-opengl-and-nanosvg-h[/url]