~ubuntu-branches/ubuntu/breezy/gimp/breezy

« back to all changes in this revision

Viewing changes to plug-ins/rcm/rcm_gdk.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-10-04 19:04:46 UTC
  • Revision ID: james.westby@ubuntu.com-20051004190446-ukh32kwk56s4sjhu
Tags: upstream-2.2.8
ImportĀ upstreamĀ versionĀ 2.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This is a plug-in for the GIMP.
 
5
 *
 
6
 * Colormap-Rotation plug-in. Exchanges two color ranges.
 
7
 *
 
8
 * Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
 
9
 *                    Based on code from Pavel Grinfeld (pavel@ml.com)
 
10
 *
 
11
 *
 
12
 * This program is free software; you can redistribute it and/or modify
 
13
 * it under the terms of the GNU General Public License as published by
 
14
 * the Free Software Foundation; either version 2 of the License, or
 
15
 * (at your option) any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with this program; if not, write to the Free Software
 
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
25
 */
 
26
 
 
27
/*----------------------------------------------------------------------------
 
28
 * Change log:
 
29
 *
 
30
 * Version 2.0, 04 April 1999.
 
31
 *  Nearly complete rewrite, made plug-in stable.
 
32
 *  (Works with GIMP 1.1 and GTK+ 1.2)
 
33
 *
 
34
 * Version 1.0, 27 March 1997.
 
35
 *  Initial (unstable) release by Pavel Grinfeld
 
36
 *
 
37
 *----------------------------------------------------------------------------*/
 
38
 
 
39
#include "config.h"
 
40
 
 
41
#include <stdio.h>
 
42
#include <stdlib.h>
 
43
 
 
44
#include <libgimp/gimp.h>
 
45
#include <libgimp/gimpui.h>
 
46
 
 
47
#include "rcm.h"
 
48
#include "rcm_misc.h"
 
49
#include "rcm_dialog.h"
 
50
#include "rcm_gdk.h"
 
51
 
 
52
 
 
53
/* Global variables */
 
54
 
 
55
GdkGC *xor_gc;
 
56
 
 
57
 
 
58
/* Drawing routines */
 
59
 
 
60
void
 
61
rcm_draw_little_circle (GdkWindow *window,
 
62
                        GdkGC     *color,
 
63
                        gfloat     hue,
 
64
                        gfloat     satur)
 
65
{
 
66
  gint x,y;
 
67
 
 
68
  x = GRAY_CENTER + GRAY_RADIUS * satur * cos(hue);
 
69
  y = GRAY_CENTER - GRAY_RADIUS * satur * sin(hue);
 
70
 
 
71
  gdk_draw_arc (window, color, 0, x-LITTLE_RADIUS, y-LITTLE_RADIUS,
 
72
                2*LITTLE_RADIUS, 2*LITTLE_RADIUS, 0, 360*64);
 
73
}
 
74
 
 
75
void
 
76
rcm_draw_large_circle (GdkWindow *window,
 
77
                       GdkGC     *color,
 
78
                       gfloat     gray_sat)
 
79
{
 
80
  gint x, y;
 
81
 
 
82
  x = GRAY_CENTER;
 
83
  y = GRAY_CENTER;
 
84
 
 
85
  gdk_draw_arc (window, color, 0,
 
86
                ROUND (x - GRAY_RADIUS * gray_sat),
 
87
                ROUND (y - GRAY_RADIUS * gray_sat),
 
88
                ROUND (2 * GRAY_RADIUS * gray_sat),
 
89
                ROUND (2 * GRAY_RADIUS * gray_sat),
 
90
                0, 360 * 64);
 
91
}
 
92
 
 
93
 
 
94
#define REL .8
 
95
#define DEL .1
 
96
#define TICK 10
 
97
 
 
98
void
 
99
rcm_draw_arrows (GdkWindow *window,
 
100
                 GdkGC     *color,
 
101
                 RcmAngle  *angle)
 
102
{
 
103
  gint   dist;
 
104
  gfloat alpha, beta, cw_ccw, delta;
 
105
 
 
106
  alpha  = angle->alpha;
 
107
  beta   = angle->beta;
 
108
  cw_ccw = angle->cw_ccw;
 
109
  delta  = angle_mod_2PI(beta - alpha);
 
110
 
 
111
  if (cw_ccw == -1)
 
112
    delta = delta - TP;
 
113
 
 
114
  gdk_draw_line (window,color,
 
115
                 CENTER,
 
116
                 CENTER,
 
117
                 ROUND (CENTER + RADIUS * cos(alpha)),
 
118
                 ROUND (CENTER - RADIUS * sin(alpha)));
 
119
 
 
120
  gdk_draw_line( window,color,
 
121
                 CENTER + RADIUS * cos(alpha),
 
122
                 CENTER - RADIUS * sin(alpha),
 
123
                 ROUND (CENTER + RADIUS * REL * cos(alpha - DEL)),
 
124
                 ROUND (CENTER - RADIUS * REL * sin(alpha - DEL)));
 
125
 
 
126
  gdk_draw_line (window,color,
 
127
                 CENTER + RADIUS * cos(alpha),
 
128
                 CENTER - RADIUS * sin(alpha),
 
129
                 ROUND (CENTER + RADIUS * REL * cos(alpha + DEL)),
 
130
                 ROUND (CENTER - RADIUS * REL * sin(alpha + DEL)));
 
131
 
 
132
  gdk_draw_line (window,color,
 
133
                 CENTER,
 
134
                 CENTER,
 
135
                 ROUND (CENTER + RADIUS * cos(beta)),
 
136
                 ROUND (CENTER - RADIUS * sin(beta)));
 
137
 
 
138
  gdk_draw_line (window,color,
 
139
                 CENTER + RADIUS * cos(beta),
 
140
                 CENTER - RADIUS * sin(beta),
 
141
                 ROUND (CENTER + RADIUS * REL * cos(beta - DEL)),
 
142
                 ROUND (CENTER - RADIUS * REL * sin(beta - DEL)));
 
143
 
 
144
  gdk_draw_line (window,color,
 
145
                 CENTER + RADIUS * cos(beta),
 
146
                 CENTER - RADIUS * sin(beta),
 
147
                 ROUND (CENTER + RADIUS * REL * cos(beta + DEL)),
 
148
                 ROUND (CENTER - RADIUS * REL * sin(beta + DEL)));
 
149
 
 
150
  dist   = RADIUS * EACH_OR_BOTH;
 
151
 
 
152
  gdk_draw_line (window,color,
 
153
                 CENTER + dist * cos(beta),
 
154
                 CENTER - dist * sin(beta),
 
155
                 ROUND (CENTER + dist * cos(beta) + cw_ccw * TICK * sin(beta)),
 
156
                 ROUND (CENTER - dist * sin(beta) + cw_ccw * TICK * cos(beta)));
 
157
 
 
158
  alpha *= 180 * 64 / G_PI;
 
159
  delta *= 180 * 64 / G_PI;
 
160
 
 
161
  gdk_draw_arc (window, color, 0, CENTER - dist, CENTER - dist,
 
162
                2*dist, 2*dist, alpha, delta);
 
163
}