#include "Abs_Axis.h"

#include <algorithm>
#include <cmath>

namespace renderive {

Abs_Axis::Abs_Axis() : Renderable(true) {}

Abs_Axis::~Abs_Axis() = default;

int Abs_Axis::pixel_sample_count(Range range) const {
    const Axis_Transform value = transform();
    const double first = value.coord_to_pixel(range.origin);
    const double last = value.coord_to_pixel(range.target);
    return std::max(0, static_cast<int>(std::abs(last - first)) + 1);
}

int Abs_Axis::sub_tick_count(double) const noexcept {
    return 4;
}

} // namespace renderive
