|
Packit Service |
2781ba |
/* This file is part of GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2006 Dominik Ernst
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Reflect an image about a line, whose direction is specified by the
|
|
Packit Service |
2781ba |
* vector that is defined by the x and y properties.
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
#include <glib/gi18n-lib.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#ifdef GEGL_CHANT_PROPERTIES
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
|
Packit Service |
2781ba |
_("Direction vector's X component"))
|
|
Packit Service |
2781ba |
gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
|
Packit Service |
2781ba |
_("Direction vector's Y component"))
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#else
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_NAME reflect
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_SELF "reflect.c"
|
|
Packit Service |
2781ba |
#include "chant.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <math.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
create_matrix (OpTransform *op,
|
|
Packit Service |
2781ba |
GeglMatrix3 *matrix)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
|
|
Packit Service |
2781ba |
gdouble ux = 0, uy = 0;
|
|
Packit Service |
2781ba |
gdouble l;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
ux = chant->x;
|
|
Packit Service |
2781ba |
uy = chant->y;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
l = sqrt(uy*uy + ux*ux);
|
|
Packit Service |
2781ba |
ux /= l;
|
|
Packit Service |
2781ba |
uy /= l;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
matrix->coeff [0][0] = 2*ux*ux - 1;
|
|
Packit Service |
2781ba |
matrix->coeff [1][1] = 2*uy*uy - 1;
|
|
Packit Service |
2781ba |
matrix->coeff [0][1] = matrix->coeff [1][0] = 2*ux*uy;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#endif
|