#include <SFML/Graphics.hpp>
#include <vector>
using namespace sf;
 
//------------------------------------------------------------------------------
 
class Axis    //: public Drawable {
{
public:
   
    Axis(int d, Vertex xy, int l, int n=0);
    void draw() {
       
    }
private:
    //enum Orientation { x, y };
    Vertex start;
    int length;
    int number_of_notches;
    std::vector<Vertex> vertices;
    //virtual void draw(RenderTarget& target, RenderStates states) const;
};
 
Axis::Axis(int d, Vertex xy, int l, int n)
{
    switch (d)
    {
    case 0:  //Axis::x:
    {
        xy.color= Color(255,255,0);
        vertices.push_back(xy);
        vertices.push_back(Vertex(Vector2f(xy.position.x+l,xy.position.y),Color(255,255,0)));
        // axis line
        if (1<n)        // add notches
        {
            int deltaX = l/n;
            int x = xy.position.x+deltaX;  // x-coord of first notch
            for (int i = 0; i<n; ++i)
            {
                vertices.push_back(Vertex(Vector2f(x,xy.position.y),Color(255,255,0)));
                vertices.push_back(Vertex(Vector2f(x,xy.position.y-10),Color(255,255,0)));
                x += deltaX;
            }
        }
//        // label under the line
//        label.move(length/3,xy.y+20);
        break;
    }
    case 1:  //Axis::y:
    {
        xy.color= Color(255,255,0);
        vertices.push_back(xy);
        vertices.push_back(Vertex(Vector2f(xy.position.x,xy.position.y-l),Color(255,255,0)));
 
        if (1<n)        // add notches
        {
            int deltaY = l/n;
            int y = xy.position.y-deltaY;  // x-coord of first notch
            for (int i = 0; i<n; ++i)
            {
                vertices.push_back(Vertex(Vector2f(xy.position.x,y),Color(255,255,0)));
                vertices.push_back(Vertex(Vector2f(xy.position.x+10,y),Color(255,255,0)));
                y -= deltaY;
            }
        }
        break;
    }
    }
}
 
 
#include "Graph.h"
#include <ctime>
#include <cstdlib>
///https://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php
using namespace sf;
 
int main() {
    srand(time(0));
    RenderWindow window(VideoMode(600, 480), "SFML works!");
 
    Axis ax(0, Vector2f(10, 240), 580, 10);
    Axis ay(1, Vector2f(300, 470), 460, 10);
 
 
//sf::Vertex vertices[2] =
//{
//    sf::Vertex(...),
//    sf::Vertex(...)
//};
 
//window.draw(vertices, 2, sf::Lines);
 
    //window.draw(vertices, 2, sf::Lines);*/
    //double x{0},y{0},xinc{0.4354},yinc{0.843};
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
        }
 
        window.clear();
 
        window.draw(&ax.vertices[0], ax.vertices.size(), Lines);
        window.draw(&ay.vertices[0], ay.vertices.size(), Lines);
        window.display();
    }
 
    return 0;
}