feat(render): halo neon proporcional al bounding_radius de la shape (opt-out a text)
This commit is contained in:
@@ -11,21 +11,21 @@
|
||||
|
||||
namespace Graphics {
|
||||
|
||||
// Tipo de primitiva dins de una shape
|
||||
enum class PrimitiveType : std::uint8_t {
|
||||
POLYLINE, // Secuencia de points connectats
|
||||
LINE // Línia individual (2 points)
|
||||
};
|
||||
// Tipo de primitiva dins de una shape
|
||||
enum class PrimitiveType : std::uint8_t {
|
||||
POLYLINE, // Secuencia de points connectats
|
||||
LINE // Línia individual (2 points)
|
||||
};
|
||||
|
||||
// Primitiva individual (polyline o line)
|
||||
struct ShapePrimitive {
|
||||
// Primitiva individual (polyline o line)
|
||||
struct ShapePrimitive {
|
||||
PrimitiveType type;
|
||||
std::vector<Vec2> points; // 2+ points per polyline, exactament 2 per line
|
||||
};
|
||||
};
|
||||
|
||||
// Clase Shape - representa una shape vectorial carregada desde .shp
|
||||
class Shape {
|
||||
public:
|
||||
// Clase Shape - representa una shape vectorial carregada desde .shp
|
||||
class Shape {
|
||||
public:
|
||||
// Constructors
|
||||
Shape() = default;
|
||||
explicit Shape(const std::string& filepath);
|
||||
@@ -42,18 +42,22 @@ class Shape {
|
||||
}
|
||||
[[nodiscard]] auto getCenter() const -> const Vec2& { return center_; }
|
||||
[[nodiscard]] auto getDefaultScale() const -> float { return escala_defecte_; }
|
||||
// Distància màx. del center_ al vèrtex més llunyà; ús: dimensionar
|
||||
// efectes proporcionals a la mida de la shape (halos, glow).
|
||||
[[nodiscard]] auto getBoundingRadius() const -> float { return bounding_radius_; }
|
||||
[[nodiscard]] auto isValid() const -> bool { return !primitives_.empty(); }
|
||||
|
||||
// Info de depuració
|
||||
[[nodiscard]] auto getName() const -> const std::string& { return nom_; }
|
||||
[[nodiscard]] auto getNumPrimitives() const -> size_t { return primitives_.size(); }
|
||||
|
||||
private:
|
||||
private:
|
||||
std::vector<ShapePrimitive> primitives_;
|
||||
Vec2 center_; // Centro/origin de la shape
|
||||
float escala_defecte_{1.0F}; // Escala per defecte (normalment 1.0). Inicializada para
|
||||
// que el ctor por defecto no deje el campo indeterminado.
|
||||
std::string nom_; // Nom de la shape (per depuració)
|
||||
Vec2 center_; // Centro/origin de la shape
|
||||
float escala_defecte_{1.0F}; // Escala per defecte (normalment 1.0). Inicializada para
|
||||
// que el ctor por defecto no deje el campo indeterminado.
|
||||
float bounding_radius_{0.0F}; // Distància màx. del center_ al vèrtex més llunyà.
|
||||
std::string nom_; // Nom de la shape (per depuració)
|
||||
|
||||
// Helpers privats per parsejar. Son estáticos: no necesitan estado
|
||||
// de instancia, trabajan sobre el string pasado por parámetro.
|
||||
@@ -62,6 +66,9 @@ class Shape {
|
||||
[[nodiscard]] static auto extractValue(const std::string& line) -> std::string;
|
||||
void parseCenter(const std::string& value);
|
||||
[[nodiscard]] static auto parsePoints(const std::string& str) -> std::vector<Vec2>;
|
||||
};
|
||||
[[nodiscard]] static auto computeBoundingRadius(
|
||||
const std::vector<ShapePrimitive>& primitives,
|
||||
const Vec2& center) -> float;
|
||||
};
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
Reference in New Issue
Block a user