/* Copyright 2026 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_point.h>

namespace Gdk
{
namespace Graphene
{

Vec2::Vec2()
:
  gobject_(*graphene_vec2_zero())
{}

Vec2::Vec2(float x, float y)
{
  (void)graphene_vec2_init(gobj(), x, y);
}

Vec2::Vec2(const Point& src)
{
  graphene_point_to_vec2(src.gobj(), gobj());
}

Vec2::Vec2(const graphene_vec2_t* vec2)
:
  gobject_(vec2 ? *vec2 : *graphene_vec2_zero())
{}

std::array<float,2> Vec2::to_float() const
{
  std::array<float,2> result;
  graphene_vec2_to_float(gobj(), result.data());
  return result;
}

Vec2 Vec2::add(const Vec2& other) const
{
  Vec2 result;
  graphene_vec2_add(gobj(), other.gobj(), result.gobj());
  return result;
}

Vec2 Vec2::subtract(const Vec2& other) const
{
  Vec2 result;
  graphene_vec2_subtract(gobj(), other.gobj(), result.gobj());
  return result;
}

Vec2 Vec2::normalize() const
{
  Vec2 result;
  graphene_vec2_normalize(gobj(), result.gobj());
  return result;
}

Vec2 Vec2::scale(float factor) const
{
  Vec2 result;
  graphene_vec2_scale(gobj(), factor, result.gobj());
  return result;
}

Vec2 Vec2::negate() const
{
  Vec2 result;
  graphene_vec2_negate(gobj(), result.gobj());
  return result;
}

Vec2 Vec2::interpolate(const Vec2& other, double factor) const
{
  Vec2 result;
  graphene_vec2_interpolate(gobj(), other.gobj(), factor, result.gobj());
  return result;
}

} // namespace Graphene
} // namespace Gdk
