/* This file is part of GEGL editor -- a gtk frontend for GEGL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see .
*
* Copyright (C) 2005, 2008 Øyvind Kolås
*/
#include "config.h"
#include "gegl-path-smooth.h"
#include
#include "gegl-path.h"
#include
static GeglPathList *
points_to_bezier_path (gdouble coord_x[],
gdouble coord_y[],
gint n_coords)
{
GeglPathList *ret = NULL;
gint i;
gdouble smooth_value;
smooth_value = 0.8;
if (!n_coords)
return NULL;
ret = gegl_path_list_append (ret, 'M', coord_x[0], coord_y[0]);
for (i=1;inext)
{
switch (iter->d.type)
{
case '*':
break;
default:
is_smooth_path=FALSE;
break;
}
count ++;
}
if (!is_smooth_path)
{
return original;
}
coordsx = g_new0 (gdouble, count);
coordsy = g_new0 (gdouble, count);
for (i=0, iter = original; iter; iter=iter->next, i++)
{
coordsx[i] = iter->d.point[0].x;
coordsy[i] = iter->d.point[0].y;
}
ret = points_to_bezier_path (coordsx, coordsy, count);
g_free (coordsx);
g_free (coordsy);
return ret;
}
void gegl_path_smooth_init (void)
{
static gboolean done = FALSE;
if (done)
return;
done = TRUE;
gegl_path_add_type ('*', 2, "path");
gegl_path_add_flattener (gegl_path_smooth_flatten);
}