
// IndexedStrokedPath.cpp - implementation of indexed stroked path for polar stroking

#include "IndexedStrokedPath.hpp"

#include <Cg/max.hpp>

const StrokeLink& IndexedStrokedPath::ClampedLink(int i) const
{
    size_t clamped_i = Cg::max(0,i);
    if (clamped_i >= link.size()) {
        clamped_i = link.size()-1;
    }
    return link[clamped_i];
}

float2 IndexedStrokedPath::cp_back()
{
    return float2(coord[coord.size()-2], coord[coord.size()-1]);

}
void IndexedStrokedPath::cp_push_back(const float2& cp)
{
    coord.push_back(cp.x);
    coord.push_back(cp.y);
}

float2 IndexedStrokedPath::cp(size_t i)
{
    return float2(coord[i], coord[i+1]);
}

void IndexedStrokedPath::swap(IndexedStrokedPath& other)
{
    other.link.swap(link);
    other.coord.swap(coord);
}