[gegl] reset-origin: new op
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] reset-origin: new op
- Date: Wed, 20 May 2020 21:52:32 +0000 (UTC)
commit 6d4b25e69f6f54a2e832da79f13832e7ea4718f8
Author: Øyvind Kolås <pippin gimp org>
Date: Wed May 20 23:45:59 2020 +0200
reset-origin: new op
operations/transform/meson.build | 1 +
operations/transform/module.c | 2 +
operations/transform/reset-origin.c | 82 +++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
4 files changed, 86 insertions(+)
---
diff --git a/operations/transform/meson.build b/operations/transform/meson.build
index 2ca378fea..3969c6c4d 100644
--- a/operations/transform/meson.build
+++ b/operations/transform/meson.build
@@ -2,6 +2,7 @@ gegl_transformops_sources = files(
'module.c',
'border-align.c',
'reflect.c',
+ 'reset-origin.c',
'rotate-on-center.c',
'rotate.c',
'scale-ratio.c',
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 4309767cb..c9fd0626e 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -43,6 +43,7 @@ GType gegl_op_border_align_register_type (GTypeModule *module);
GType gegl_op_rotate_register_type (GTypeModule *module);
GType gegl_op_rotate_on_center_register_type (GTypeModule *module);
GType gegl_op_reflect_register_type (GTypeModule *module);
+GType gegl_op_reset_origin_register_type (GTypeModule *module);
GType gegl_op_scale_ratio_register_type (GTypeModule *module);
GType gegl_op_scale_size_register_type (GTypeModule *module);
GType gegl_op_scale_size_keepaspect_register_type (GTypeModule *module);
@@ -68,6 +69,7 @@ gegl_module_register (GTypeModule *module)
dummy = gegl_op_shear_register_type (module);
dummy = gegl_op_translate_register_type (module);
dummy = gegl_op_transform_register_type (module);
+ dummy = gegl_op_reset_origin_register_type (module);
dummy = gegl_op_rotate_on_center_register_type (module);
dummy ++; /* silence gcc, having it is required to avoid optimizing
diff --git a/operations/transform/reset-origin.c b/operations/transform/reset-origin.c
new file mode 100644
index 000000000..5dcc569e2
--- /dev/null
+++ b/operations/transform/reset-origin.c
@@ -0,0 +1,82 @@
+/* This file is part of GEGL
+ *
+ * GEGL 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 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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 GEGL; if not, see <https://www.gnu.org/licenses/>.
+ *
+ * Copyright 2020 Øyvind Kolås
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#ifdef GEGL_PROPERTIES
+
+#else
+
+#include "gegl-operation-filter.h"
+#include "transform-core.h"
+#define GEGL_OP_NO_SOURCE
+#define GEGL_OP_Parent OpTransform
+#define GEGL_OP_PARENT TYPE_OP_TRANSFORM
+#define GEGL_OP_NAME reset_origin
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE "reset-origin.c"
+
+#include "gegl-op.h"
+
+#include <math.h>
+#include <stdio.h>
+
+static void
+create_matrix (OpTransform *op,
+ GeglMatrix3 *matrix)
+{
+ GeglOperation *operation = GEGL_OPERATION (op);
+
+ gdouble x = 0.0;
+ gdouble y = 0.0;
+
+ GeglNode *box_node = gegl_operation_get_source_node (operation, "input");
+
+ GeglRectangle box_rect = {0,};
+
+ if (box_node)
+ box_rect = gegl_node_get_bounding_box (box_node);
+
+ x = -box_rect.x;
+ y = -box_rect.y;
+
+ matrix->coeff [0][2] = x;
+ matrix->coeff [1][2] = y;
+}
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+ GeglOperationClass *operation_class;
+ OpTransformClass *transform_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ transform_class = OP_TRANSFORM_CLASS (klass);
+
+ transform_class->create_matrix = create_matrix;
+
+ gegl_operation_class_set_keys (operation_class,
+ "name", "gegl:reset-origin",
+ "title", _("Reset origin"),
+ "categories", "transform",
+ "description", _("Translate top-left to 0,0."),
+ NULL);
+}
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8ace58be3..f3f0eb531 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -254,6 +254,7 @@ operations/seamless-clone/seamless-clone.c
operations/seamless-clone/seamless-clone-compose.c
operations/transform/border-align.c
operations/transform/reflect.c
+operations/transform/reset-origin.c
operations/transform/rotate.c
operations/transform/rotate-on-center.c
operations/transform/scale.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]