/* Copyright (C) 2007 The cluttermm 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, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <clutter/clutter.h>

namespace Clutter
{

// static
Glib::RefPtr<BehaviourPath> BehaviourPath::create_with_knots(const Glib::RefPtr<Alpha>& alpha,
                                                             const std::vector<Knot>& knots)
{
  const Glib::RefPtr<Path> path = Path::create();
  const Knot* data  = knots.data();
  const int n_knots = knots.size();

  if (n_knots > 0)
  {
    clutter_path_add_move_to(path->gobj(), data[0].gobj()->x, data[0].gobj()->y);

    for (int i = 1; i < n_knots; ++i)
      clutter_path_add_line_to(path->gobj(), data[i].gobj()->x, data[i].gobj()->y);
  }

  return Glib::RefPtr<BehaviourPath>(new BehaviourPath(alpha, path));
}

// static
Glib::RefPtr<BehaviourPath> create_with_description(const Glib::RefPtr<Alpha>& alpha,
                                                    const Glib::ustring& description)
{
  return BehaviourPath::create(alpha, Path::create(description));
}

} // namespace Clutter
