Commit 34f76ba3 authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist
Browse files

In the case of angular selection, offset angle with G_PI/2 to be

1999-08-28  Tor Lillqvist  <tml@iki.fi>

* app/gimpbrushpipe.c (gimp_brush_pixmap_select_brush): In the
case of angular selection, offset angle with G_PI/2 to be
compatible with PSP tubes. Restrict the index of each dimension
separately to the appropriate range.

* plug-ins/common/gpb.c (gih_save_dialog): Must not free the combo
box string list, the strings are not strdup'ed by the combo box.
parent 75074882
1999-08-28 Tor Lillqvist <tml@iki.fi>
* app/gimpbrushpipe.c (gimp_brush_pixmap_select_brush): In the
case of angular selection, offset angle with G_PI/2 to be
compatible with PSP tubes. Restrict the index of each dimension
separately to the appropriate range.
* plug-ins/common/gpb.c (gih_save_dialog): Must not free the combo
box string list, the strings are not strdup'ed by the combo box.
Fri Aug 27 18:15:33 PDT 1999 Manish Singh <yosh@gimp.org>
* app/gdisplay_color.c: more work on the gamma correction stuff
......
......@@ -129,7 +129,7 @@ static GimpBrush *
gimp_brush_pixmap_select_brush (PaintCore *paint_core)
{
GimpBrushPipe *pipe;
int i, brushix, value;
int i, brushix, ix;
double angle;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), NULL);
......@@ -145,38 +145,43 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
switch (pipe->select[i])
{
case PIPE_SELECT_CONSTANT:
/* What constant? */
value = 0;
ix = pipe->index[i];
break;
case PIPE_SELECT_INCREMENTAL:
value = pipe->index[i] = (pipe->index[i] + 1) % pipe->rank[i];
ix = (pipe->index[i] + 1) % pipe->rank[i];
break;
case PIPE_SELECT_ANGULAR:
angle = atan2 (paint_core->cury - paint_core->lasty,
paint_core->curx - paint_core->lastx);
/* Offset angle to be compatible with PSP tubes */
angle += G_PI_2;
/* Map it to the [0..2*G_PI) interval */
if (angle < 0)
angle += 2.*G_PI;
value = RINT (angle / (2.*G_PI) * pipe->rank[i]);
else if (angle > 2.*G_PI)
angle -= 2.*G_PI;
ix = RINT (angle / (2.*G_PI) * pipe->rank[i]);
break;
case PIPE_SELECT_RANDOM:
/* This probably isn't the right way */
value = rand () % pipe->rank[i];
ix = rand () % pipe->rank[i];
break;
case PIPE_SELECT_PRESSURE:
value = RINT (paint_core->curpressure * (pipe->rank[i] - 1));
ix = RINT (paint_core->curpressure * (pipe->rank[i] - 1));
break;
case PIPE_SELECT_TILT_X:
value = RINT (paint_core->curxtilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
ix = RINT (paint_core->curxtilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
break;
case PIPE_SELECT_TILT_Y:
value = RINT (paint_core->curytilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
ix = RINT (paint_core->curytilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
break;
}
brushix += pipe->stride[i] * value;
/* g_print ("value at %d: %d, brushix: %d\n", i, value, brushix); */
pipe->index[i] = BOUNDS (ix, 0, pipe->rank[i]-1);
brushix += pipe->stride[i] * pipe->index[i];
/* g_print ("ix at %d: %d, brushix: %d\n", i, ix, brushix); */
}
/* If out of bounds, just select the first brush... */
/* Make sure is inside bounds */
brushix = BOUNDS (brushix, 0, pipe->nbrushes-1);
pipe->current = pipe->brushes[brushix];
......
......@@ -129,7 +129,7 @@ static GimpBrush *
gimp_brush_pixmap_select_brush (PaintCore *paint_core)
{
GimpBrushPipe *pipe;
int i, brushix, value;
int i, brushix, ix;
double angle;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), NULL);
......@@ -145,38 +145,43 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
switch (pipe->select[i])
{
case PIPE_SELECT_CONSTANT:
/* What constant? */
value = 0;
ix = pipe->index[i];
break;
case PIPE_SELECT_INCREMENTAL:
value = pipe->index[i] = (pipe->index[i] + 1) % pipe->rank[i];
ix = (pipe->index[i] + 1) % pipe->rank[i];
break;
case PIPE_SELECT_ANGULAR:
angle = atan2 (paint_core->cury - paint_core->lasty,
paint_core->curx - paint_core->lastx);
/* Offset angle to be compatible with PSP tubes */
angle += G_PI_2;
/* Map it to the [0..2*G_PI) interval */
if (angle < 0)
angle += 2.*G_PI;
value = RINT (angle / (2.*G_PI) * pipe->rank[i]);
else if (angle > 2.*G_PI)
angle -= 2.*G_PI;
ix = RINT (angle / (2.*G_PI) * pipe->rank[i]);
break;
case PIPE_SELECT_RANDOM:
/* This probably isn't the right way */
value = rand () % pipe->rank[i];
ix = rand () % pipe->rank[i];
break;
case PIPE_SELECT_PRESSURE:
value = RINT (paint_core->curpressure * (pipe->rank[i] - 1));
ix = RINT (paint_core->curpressure * (pipe->rank[i] - 1));
break;
case PIPE_SELECT_TILT_X:
value = RINT (paint_core->curxtilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
ix = RINT (paint_core->curxtilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
break;
case PIPE_SELECT_TILT_Y:
value = RINT (paint_core->curytilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
ix = RINT (paint_core->curytilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
break;
}
brushix += pipe->stride[i] * value;
/* g_print ("value at %d: %d, brushix: %d\n", i, value, brushix); */
pipe->index[i] = BOUNDS (ix, 0, pipe->rank[i]-1);
brushix += pipe->stride[i] * pipe->index[i];
/* g_print ("ix at %d: %d, brushix: %d\n", i, ix, brushix); */
}
/* If out of bounds, just select the first brush... */
/* Make sure is inside bounds */
brushix = BOUNDS (brushix, 0, pipe->nbrushes-1);
pipe->current = pipe->brushes[brushix];
......
......@@ -129,7 +129,7 @@ static GimpBrush *
gimp_brush_pixmap_select_brush (PaintCore *paint_core)
{
GimpBrushPipe *pipe;
int i, brushix, value;
int i, brushix, ix;
double angle;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), NULL);
......@@ -145,38 +145,43 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
switch (pipe->select[i])
{
case PIPE_SELECT_CONSTANT:
/* What constant? */
value = 0;
ix = pipe->index[i];
break;
case PIPE_SELECT_INCREMENTAL:
value = pipe->index[i] = (pipe->index[i] + 1) % pipe->rank[i];
ix = (pipe->index[i] + 1) % pipe->rank[i];
break;
case PIPE_SELECT_ANGULAR:
angle = atan2 (paint_core->cury - paint_core->lasty,
paint_core->curx - paint_core->lastx);
/* Offset angle to be compatible with PSP tubes */
angle += G_PI_2;
/* Map it to the [0..2*G_PI) interval */
if (angle < 0)
angle += 2.*G_PI;
value = RINT (angle / (2.*G_PI) * pipe->rank[i]);
else if (angle > 2.*G_PI)
angle -= 2.*G_PI;
ix = RINT (angle / (2.*G_PI) * pipe->rank[i]);
break;
case PIPE_SELECT_RANDOM:
/* This probably isn't the right way */
value = rand () % pipe->rank[i];
ix = rand () % pipe->rank[i];
break;
case PIPE_SELECT_PRESSURE:
value = RINT (paint_core->curpressure * (pipe->rank[i] - 1));
ix = RINT (paint_core->curpressure * (pipe->rank[i] - 1));
break;
case PIPE_SELECT_TILT_X:
value = RINT (paint_core->curxtilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
ix = RINT (paint_core->curxtilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
break;
case PIPE_SELECT_TILT_Y:
value = RINT (paint_core->curytilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
ix = RINT (paint_core->curytilt / 2.0 * pipe->rank[i]) + pipe->rank[i]/2;
break;
}
brushix += pipe->stride[i] * value;
/* g_print ("value at %d: %d, brushix: %d\n", i, value, brushix); */
pipe->index[i] = BOUNDS (ix, 0, pipe->rank[i]-1);
brushix += pipe->stride[i] * pipe->index[i];
/* g_print ("ix at %d: %d, brushix: %d\n", i, ix, brushix); */
}
/* If out of bounds, just select the first brush... */
/* Make sure is inside bounds */
brushix = BOUNDS (brushix, 0, pipe->nbrushes-1);
pipe->current = pipe->brushes[brushix];
......
......@@ -549,8 +549,6 @@ gih_save_dialog ()
gtk_widget_show (cb);
}
g_list_free (cbitems);
gtk_table_attach (GTK_TABLE (table), box, 1, 2,
GTK_TABLE (table)->nrows - 1, GTK_TABLE (table)->nrows,
GTK_SHRINK, GTK_EXPAND | GTK_FILL, 0, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment