aboutsummaryrefslogtreecommitdiff
path: root/geometry.h
blob: 200782ce9af86c74cc730af027a5ad9a44b1830d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef GEOMETRY_H
#define GEOMETRY_H

class Point2D
{
public:
    Point2D();

    void set(float, float);
    float x() const { return m_x; }
    float y() const { return m_y; }

private:
    float m_x, m_y;
};

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

    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 intersects(const RectF &) const;

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

class Geometry
{
public:
    Geometry();

    int vertexCount() const;
    Point2D *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