/* Copyright 2023 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gdkmm/graphene_vec2.h>
#include <graphene.h>

namespace
{
graphene_point_t* gdkmm_graphene_point_copy(const graphene_point_t* other)
{
  return graphene_point_init_from_point(graphene_point_alloc(), other);
}
} // anonymous namespace

namespace Gdk
{
namespace Graphene
{

Point::Point(float x, float y)
{
  gobject_ = graphene_point_init(graphene_point_alloc(), x, y);
}

Point::Point(const Vec2& src)
{
  gobject_ = graphene_point_init_from_vec2(graphene_point_alloc(), src.gobj());
}

Point::operator bool() const
{
  return gobj();
}

std::array<float,3> Point::distance(const Point& b) const
{
  float x = 0.0;
  float y = 0.0;
  const float dist = graphene_point_distance(gobj(), b.gobj(), &x, &y);
  return {dist, x, y};
}

Point Point::interpolate(const Point& b, double factor) const
{
  Point result(0.0, 0.0);
  graphene_point_interpolate(gobj(), b.gobj(), factor, result.gobj());
  return result;
}

} //namespace Graphene
} //namespace Gdk
