[gegl] linear-gradient: Remove unnecessary sqrt()
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] linear-gradient: Remove unnecessary sqrt()
- Date: Sat, 28 Mar 2015 02:48:29 +0000 (UTC)
commit 9b14848c4a156b886cf878626313637cb937d26a
Author: Daniel Sabo <DanielSabo gmail com>
Date: Fri Mar 27 19:38:32 2015 -0700
linear-gradient: Remove unnecessary sqrt()
The old math was effectively sqrt(x^2+y^2)^2.
operations/common/linear-gradient.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/operations/common/linear-gradient.c b/operations/common/linear-gradient.c
index 3aca0cf..642134e 100644
--- a/operations/common/linear-gradient.c
+++ b/operations/common/linear-gradient.c
@@ -81,7 +81,7 @@ process (GeglOperation *operation,
dx = o->end_x - o->start_x;
dy = o->end_y - o->start_y;
- length = sqrtf (dx * dx + dy * dy);
+ length = dx * dx + dy * dy;
if (GEGL_FLOAT_IS_ZERO (length))
{
@@ -101,7 +101,7 @@ process (GeglOperation *operation,
for (x = roi->x; x < roi->x + roi->width; ++x)
{
gint c;
- gfloat v = (vec0 * (x - o->start_x) + vec1 * (y - o->start_y)) / length;
+ gfloat v = vec0 * (x - o->start_x) + vec1 * (y - o->start_y);
if (v > 1.0f - GEGL_FLOAT_EPSILON)
v = 1.0f;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]