1999-04-06 04:31:20 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2007-06-06 16:44:52 +08:00
|
|
|
* This is a plug-in for GIMP.
|
1999-04-06 04:31:20 +08:00
|
|
|
*
|
|
|
|
* Colormap-Rotation plug-in. Exchanges two color ranges.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
|
|
|
|
* Based on code from Pavel Grinfeld (pavel@ml.com)
|
|
|
|
*
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1999-04-06 04:31:20 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1999-04-06 04:31:20 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-04-06 04:31:20 +08:00
|
|
|
*/
|
|
|
|
|
2004-01-30 19:53:28 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
1999-04-06 04:31:20 +08:00
|
|
|
* Change log:
|
2004-01-30 19:53:28 +08:00
|
|
|
*
|
1999-04-06 04:31:20 +08:00
|
|
|
* Version 2.0, 04 April 1999.
|
|
|
|
* Nearly complete rewrite, made plug-in stable.
|
|
|
|
* (Works with GIMP 1.1 and GTK+ 1.2)
|
|
|
|
*
|
|
|
|
* Version 1.0, 27 March 1997.
|
|
|
|
* Initial (unstable) release by Pavel Grinfeld
|
|
|
|
*
|
2004-01-30 19:53:28 +08:00
|
|
|
*----------------------------------------------------------------------------*/
|
1999-04-06 04:31:20 +08:00
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-04-06 04:31:20 +08:00
|
|
|
#include <libgimp/gimp.h>
|
2004-01-30 19:53:28 +08:00
|
|
|
#include <libgimp/gimpui.h>
|
1999-04-06 04:31:20 +08:00
|
|
|
|
2008-03-25 03:00:10 +08:00
|
|
|
#include "color-rotate.h"
|
|
|
|
#include "color-rotate-utils.h"
|
|
|
|
#include "color-rotate-dialog.h"
|
|
|
|
#include "color-rotate-draw.h"
|
1999-04-06 04:31:20 +08:00
|
|
|
|
2004-01-30 19:53:28 +08:00
|
|
|
|
1999-04-06 04:31:20 +08:00
|
|
|
/* Drawing routines */
|
|
|
|
|
2004-01-30 19:53:28 +08:00
|
|
|
void
|
2010-09-10 03:50:55 +08:00
|
|
|
color_rotate_draw_little_circle (cairo_t *cr,
|
|
|
|
gfloat hue,
|
|
|
|
gfloat satur)
|
1999-04-06 04:31:20 +08:00
|
|
|
{
|
2010-09-10 03:50:55 +08:00
|
|
|
gint x, y;
|
1999-04-06 04:31:20 +08:00
|
|
|
|
|
|
|
x = GRAY_CENTER + GRAY_RADIUS * satur * cos(hue);
|
|
|
|
y = GRAY_CENTER - GRAY_RADIUS * satur * sin(hue);
|
|
|
|
|
2010-09-10 03:50:55 +08:00
|
|
|
cairo_new_sub_path (cr);
|
|
|
|
cairo_arc (cr, x, y, LITTLE_RADIUS, 0, 2 * G_PI);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 3.0);
|
|
|
|
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
|
|
|
|
cairo_stroke_preserve (cr);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
|
|
|
|
cairo_stroke (cr);
|
1999-04-06 04:31:20 +08:00
|
|
|
}
|
|
|
|
|
2004-01-30 19:53:28 +08:00
|
|
|
void
|
2010-09-10 03:50:55 +08:00
|
|
|
color_rotate_draw_large_circle (cairo_t *cr,
|
|
|
|
gfloat gray_sat)
|
1999-04-06 04:31:20 +08:00
|
|
|
{
|
2004-01-30 19:53:28 +08:00
|
|
|
gint x, y;
|
1999-04-06 04:31:20 +08:00
|
|
|
|
|
|
|
x = GRAY_CENTER;
|
|
|
|
y = GRAY_CENTER;
|
|
|
|
|
2010-09-10 03:50:55 +08:00
|
|
|
cairo_new_sub_path (cr);
|
|
|
|
cairo_arc (cr, x, y, GRAY_RADIUS * gray_sat, 0, 2 * G_PI);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 3.0);
|
|
|
|
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
|
|
|
|
cairo_stroke_preserve (cr);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
|
|
|
|
cairo_stroke (cr);
|
1999-04-06 04:31:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-10 03:50:55 +08:00
|
|
|
#define REL 0.8
|
|
|
|
#define DEL 0.1
|
1999-04-06 04:31:20 +08:00
|
|
|
#define TICK 10
|
|
|
|
|
2004-01-30 19:53:28 +08:00
|
|
|
void
|
2010-09-10 03:50:55 +08:00
|
|
|
color_rotate_draw_arrows (cairo_t *cr,
|
|
|
|
RcmAngle *angle)
|
1999-04-06 04:31:20 +08:00
|
|
|
{
|
2004-01-30 19:53:28 +08:00
|
|
|
gint dist;
|
|
|
|
gfloat alpha, beta, cw_ccw, delta;
|
|
|
|
|
|
|
|
alpha = angle->alpha;
|
|
|
|
beta = angle->beta;
|
1999-04-06 04:31:20 +08:00
|
|
|
cw_ccw = angle->cw_ccw;
|
2010-09-10 03:50:55 +08:00
|
|
|
delta = angle_mod_2PI (beta - alpha);
|
2004-01-30 19:53:28 +08:00
|
|
|
|
|
|
|
if (cw_ccw == -1)
|
|
|
|
delta = delta - TP;
|
|
|
|
|
2010-09-10 03:50:55 +08:00
|
|
|
cairo_move_to (cr, CENTER, CENTER);
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + RADIUS * cos (alpha)),
|
|
|
|
ROUND (CENTER - RADIUS * sin (alpha)));
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
CENTER + RADIUS * cos (alpha),
|
|
|
|
CENTER - RADIUS * sin (alpha));
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + RADIUS * REL * cos (alpha - DEL)),
|
|
|
|
ROUND (CENTER - RADIUS * REL * sin (alpha - DEL)));
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
CENTER + RADIUS * cos (alpha),
|
|
|
|
CENTER - RADIUS * sin (alpha));
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + RADIUS * REL * cos (alpha + DEL)),
|
|
|
|
ROUND (CENTER - RADIUS * REL * sin (alpha + DEL)));
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
2004-01-30 19:53:28 +08:00
|
|
|
CENTER,
|
2010-09-10 03:50:55 +08:00
|
|
|
CENTER);
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + RADIUS * cos (beta)),
|
|
|
|
ROUND (CENTER - RADIUS * sin (beta)));
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
CENTER + RADIUS * cos (beta),
|
|
|
|
CENTER - RADIUS * sin (beta));
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + RADIUS * REL * cos (beta - DEL)),
|
|
|
|
ROUND (CENTER - RADIUS * REL * sin (beta - DEL)));
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
CENTER + RADIUS * cos (beta),
|
|
|
|
CENTER - RADIUS * sin (beta));
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + RADIUS * REL * cos (beta + DEL)),
|
|
|
|
ROUND (CENTER - RADIUS * REL * sin (beta + DEL)));
|
|
|
|
|
|
|
|
dist = RADIUS * EACH_OR_BOTH;
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
CENTER + dist * cos (beta),
|
|
|
|
CENTER - dist * sin (beta));
|
|
|
|
cairo_line_to (cr,
|
|
|
|
ROUND (CENTER + dist * cos(beta) + cw_ccw * TICK * sin (beta)),
|
|
|
|
ROUND (CENTER - dist * sin(beta) + cw_ccw * TICK * cos (beta)));
|
|
|
|
|
|
|
|
cairo_new_sub_path (cr);
|
|
|
|
|
|
|
|
if (cw_ccw > 0)
|
|
|
|
{
|
|
|
|
cairo_arc_negative (cr,
|
|
|
|
CENTER,
|
|
|
|
CENTER,
|
|
|
|
dist,
|
|
|
|
-alpha,
|
|
|
|
-beta);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cairo_arc (cr,
|
2004-01-30 19:53:28 +08:00
|
|
|
CENTER,
|
|
|
|
CENTER,
|
2010-09-10 03:50:55 +08:00
|
|
|
dist,
|
|
|
|
-alpha,
|
|
|
|
-beta);
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 3.0);
|
|
|
|
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
|
|
|
|
cairo_stroke_preserve (cr);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
|
|
|
|
cairo_stroke (cr);
|
1999-04-06 04:31:20 +08:00
|
|
|
}
|