aboutsummaryrefslogtreecommitdiff
#ifndef GEOMETRY_H
#define GEOMETRY_H

struct vec2
{
    float x, y;

    void set(float _x, float _y) {
        x = _x;
        y = _y;
    }
};

class RectF
{
public:
    RectF(float, float, float, float);
    RectF(const RectF &);
    RectF(const vec2 &, const vec2 &);

    float x() const { return m_x; }
    float y() const { return m_y; }
    float width() const { return m_width; }
    float height() const { return m_height; }

    bool contains(float x, float y) const;
    bool contains(const vec2 &) const;
    bool intersects(const RectF &) const;

private:
    float m_x, m_y, m_width, m_height;
};

class Geometry
{
public:
    Geometry();

    int vertexCount() const;
    vec2 *vertexDataAsPoint2D();

private:
};

// Circle
int calculateCircleVertexCount(float radius);
void updateCircleGeometry(Geometry *geometry, float radius, float cx, float cy);

// Rect
void updateRectGeometry(Geometry *geometry, float x, float y, float w, float h);

// Crosshair
void updateCrossHairGeometry(Geometry *geometry,
                             float x,
                             float y,
                             float thickness,
                             float length);
#endif // GEOMETRY_H