[gimp/warp-wip-rebased: 27/56] gimpoperationwarp: make stamp round shapped
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/warp-wip-rebased: 27/56] gimpoperationwarp: make stamp round shapped
- Date: Sat, 18 May 2013 13:56:13 +0000 (UTC)
commit 06274aac8ea6119999cb24ee9c82c5d4fc581438
Author: Michael Muré <batolettre gmail com>
Date: Sat Jun 18 18:59:09 2011 +0200
gimpoperationwarp: make stamp round shapped
app/gegl/gimpoperationwarp.c | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/app/gegl/gimpoperationwarp.c b/app/gegl/gimpoperationwarp.c
index 2b3d3bc..57f66af 100644
--- a/app/gegl/gimpoperationwarp.c
+++ b/app/gegl/gimpoperationwarp.c
@@ -23,6 +23,7 @@
#include <gegl-buffer-iterator.h>
#include "libgimpconfig/gimpconfig.h"
+#include "libgimpmath/gimpmath.h"
#include "gimp-gegl-types.h"
@@ -52,9 +53,11 @@ static gboolean gimp_operation_warp_process (GeglOperation *op
GeglBuffer *in_buf,
GeglBuffer *out_buf,
const GeglRectangle *roi);
-void gimp_operation_warp_affect (const GeglPathItem *knot,
+static void gimp_operation_warp_affect (const GeglPathItem *knot,
gpointer data);
-
+static gdouble gimp_operation_warp_get_influence (GimpOperationWarp *ow,
+ gfloat x,
+ gfloat y);
G_DEFINE_TYPE (GimpOperationWarp, gimp_operation_warp,
GEGL_TYPE_OPERATION_FILTER)
@@ -208,9 +211,10 @@ gimp_operation_warp_affect (const GeglPathItem *knot,
GeglBufferIterator *it;
Babl *format;
+ gfloat influence;
gint x, y;
- GeglRectangle area = {knot->point->x - 20,
- knot->point->y - 20,
+ GeglRectangle area = {knot->point->x - ow->size / 2.0,
+ knot->point->y - ow->size / 2.0,
ow->size,
ow->size};
@@ -236,8 +240,12 @@ gimp_operation_warp_affect (const GeglPathItem *knot,
while (n_pixels--)
{
- coords[0] += (ow->last_point.x - knot->point->x);
- coords[1] += (ow->last_point.y - knot->point->y);
+ influence = gimp_operation_warp_get_influence (ow,
+ x - knot->point->x,
+ y - knot->point->y);
+
+ coords[0] += influence * (ow->last_point.x - knot->point->x);
+ coords[1] += influence * (ow->last_point.y - knot->point->y);
coords += 2;
@@ -252,4 +260,14 @@ gimp_operation_warp_affect (const GeglPathItem *knot,
}
ow->last_point = *(knot->point);
-}
\ No newline at end of file
+}
+
+static gdouble
+gimp_operation_warp_get_influence (GimpOperationWarp *ow,
+ gfloat x,
+ gfloat y)
+{
+ gfloat radius = sqrt(x*x+y*y);
+
+ return (radius < ow->size / 2.0) ? ow->strength : 0.0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]