#pragma once

#include "../base/Types.h"

#include <cstddef>
#include <string>

namespace renderive {

struct Axis_Transform {
    Range coordinate_range;
    double pixel_origin{};
    double pixel_length{};
    Orientation orientation = Orientation::Horizontal;

    [[nodiscard]] double coord_to_pixel(double coordinate) const noexcept {
        const double span = coordinate_range.length();
        if (span == 0.0)
            return pixel_origin;
        return pixel_origin + (coordinate - coordinate_range.origin) / span * pixel_length;
    }
    [[nodiscard]] double pixel_to_coord(double pixel) const noexcept {
        if (pixel_length == 0.0)
            return coordinate_range.origin;
        return coordinate_range.origin + (pixel - pixel_origin) / pixel_length * coordinate_range.length();
    }

    [[nodiscard]] double point_to_coord(PointF point) const noexcept {
        return pixel_to_coord(orientation == Orientation::Horizontal ? point.x : point.y);
    }
};

struct Axis_Base_Properties {
    int x{};
    int y{};
    Orientation orientation = Orientation::Horizontal;
    std::size_t pixel_length{};
    int tick_length = 10;
    int sub_tick_length = 5;
    Color color = Color::white();
    Number_Locale locale;
    std::string unit_text;
    Font unit_text_font;
    Pen unit_text_pen{Color::white()};
    Brush unit_text_background_brush{Color::black(), Brush_Style::Solid};
    int label_rotation_degrees{};
};

} // namespace renderive
