GtkGamma/Curve enhancement
- From: Vidar Madsen <vidar vidar prosalg no>
- To: gtk-list redhat com
- Subject: GtkGamma/Curve enhancement
- Date: Fri, 27 Mar 1998 16:35:40 +0100 (CET)
Hi all.
I've just put together a trivial patch to allow GtkCurve and GtkGamma to
accept negative gamma-values, much the same way xv's color editor does it.
Negative values simply causes the curve to be drawn "backwards", a pretty
useful feature if you ask me.
Another thing. Is there a new deadline set for v1.0 now?
Thanks,
Vidar
--- gtkcurve.c-orig Fri Mar 27 13:15:54 1998
+++ gtkcurve.c Fri Mar 27 13:18:10 1998
@@ -639,6 +639,7 @@
gfloat x, one_over_gamma, height, one_over_width;
GtkCurveType old_type;
gint i;
+ gint neg = 0;
if (c->num_points < 2)
return;
@@ -646,18 +647,27 @@
old_type = c->curve_type;
c->curve_type = GTK_CURVE_TYPE_FREE;
- if (gamma <= 0)
+ if (gamma < 0) {
+ neg = 1;
+ gamma = -gamma;
+ }
+ if(gamma == 0)
one_over_gamma = 1.0;
else
one_over_gamma = 1.0 / gamma;
+
one_over_width = 1.0 / (c->num_points - 1);
height = c->height;
for (i = 0; i < c->num_points; ++i)
{
x = (gfloat) i / (c->num_points - 1);
c->point[i].x = RADIUS + i;
- c->point[i].y =
- RADIUS + (height * (1.0 - pow (x, one_over_gamma)) + 0.5);
+ if(!neg)
+ c->point[i].y =
+ RADIUS + (height * (1.0 - pow (x, one_over_gamma)) + 0.5);
+ else
+ c->point[c->num_points-1-i].y =
+ RADIUS + (height * (1.0 - pow (x, one_over_gamma)) + 0.5);
}
if (old_type != GTK_CURVE_TYPE_FREE)
--- gtkgamma.c-orig Fri Mar 27 13:14:40 1998
+++ gtkgamma.c Fri Mar 27 13:15:48 1998
@@ -357,7 +357,7 @@
if (start)
{
v = strtod (start, &end);
- if (end > start && v > 0.0)
+ if (end > start)
c->gamma = v;
}
gtk_curve_set_gamma (GTK_CURVE (c->curve), c->gamma);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]