Программы на C++. Форум разработчиков
Anonymous
Latex SVG -файл неправильно отображается в C ++ с OpenGl и NanoSvg.h
Сообщение
Anonymous » 15 июл 2025, 12:16
Я пытаюсь отобразить уравнение avation.svg уравнение латекса с использованием opengl и [nanosvg.h] [1] , но результат искажен, и я надеялся, что кто -то сможет указать мне в правильном направлении, как его исправить. Код в main.cpp является следующим:
Код: Выделить всё
#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]
1752570962
Anonymous
Я пытаюсь отобразить уравнение avation.svg уравнение латекса с использованием opengl и [nanosvg.h] [1] , но результат искажен, и я надеялся, что кто -то сможет указать мне в правильном направлении, как его исправить. Код в main.cpp является следующим: [code]#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]