~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to modules/colorsel_triangle.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
{
138
138
  if (! colorsel_triangle_type)
139
139
    {
140
 
      static const GTypeInfo select_info =
 
140
      const GTypeInfo select_info =
141
141
      {
142
142
        sizeof (ColorselTriangleClass),
143
143
        (GBaseInitFunc) NULL,
210
210
 
211
211
  gtk_widget_add_events (preview, PREVIEW_MASK);
212
212
 
213
 
  g_signal_connect (preview, "motion_notify_event",
214
 
                    G_CALLBACK (colorsel_triangle_event),
215
 
                    triangle);
216
 
  g_signal_connect (preview, "button_press_event",
217
 
                    G_CALLBACK (colorsel_triangle_event),
218
 
                    triangle);
219
 
  g_signal_connect (preview, "button_release_event",
 
213
  g_signal_connect (preview, "motion-notify-event",
 
214
                    G_CALLBACK (colorsel_triangle_event),
 
215
                    triangle);
 
216
  g_signal_connect (preview, "button-press-event",
 
217
                    G_CALLBACK (colorsel_triangle_event),
 
218
                    triangle);
 
219
  g_signal_connect (preview, "button-release-event",
220
220
                    G_CALLBACK (colorsel_triangle_event),
221
221
                    triangle);
222
222
 
223
 
  g_signal_connect (preview, "size_allocate",
 
223
  g_signal_connect (preview, "size-allocate",
224
224
                    G_CALLBACK (colorsel_triangle_size_allocate),
225
225
                    triangle);
226
226
 
261
261
  hue = (gdouble) selector->hsv.h * 2 * G_PI;
262
262
 
263
263
  /* Colored point (value = 1, saturation = 1) */
264
 
  hx = RINT (sin (hue) * triangle->triangleradius);
265
 
  hy = RINT (cos (hue) * triangle->triangleradius);
 
264
  hx = RINT (cos (hue) * triangle->triangleradius);
 
265
  hy = RINT (sin (hue) * triangle->triangleradius);
266
266
 
267
267
  /* Black point (value = 0, saturation not important) */
268
 
  sx = RINT (sin (hue - 2 * G_PI / 3) * triangle->triangleradius);
269
 
  sy = RINT (cos (hue - 2 * G_PI / 3) * triangle->triangleradius);
 
268
  sx = RINT (cos (hue + 2 * G_PI / 3) * triangle->triangleradius);
 
269
  sy = RINT (sin (hue + 2 * G_PI / 3) * triangle->triangleradius);
270
270
 
271
271
  /* White point (value = 1, saturation = 0) */
272
 
  vx = RINT (sin (hue + 2 * G_PI / 3) * triangle->triangleradius);
273
 
  vy = RINT (cos (hue + 2 * G_PI / 3) * triangle->triangleradius);
 
272
  vx = RINT (cos (hue - 2 * G_PI / 3) * triangle->triangleradius);
 
273
  vy = RINT (sin (hue - 2 * G_PI / 3) * triangle->triangleradius);
274
274
 
275
275
  hue = selector->hsv.h * 360.0;
276
276
 
286
286
            {
287
287
              if (r2 > SQR (triangle->triangleradius))
288
288
                {
289
 
                  atn = atan2 (x, y);
 
289
                  atn = atan2 (y, x);
290
290
                  if (atn < 0)
291
291
                    atn = atn + 2 * G_PI;
292
292
 
310
310
 
311
311
  /* marker in outer ring */
312
312
 
313
 
  x0 = RINT (sin (hue * G_PI / 180) *
 
313
  x0 = RINT (cos (hue * G_PI / 180) *
314
314
             ((gdouble) (triangle->wheelradius -
315
315
                         triangle->triangleradius + 1) / 2 +
316
316
              triangle->triangleradius));
317
 
  y0 = RINT (cos (hue * G_PI / 180) *
 
317
  y0 = RINT (sin (hue * G_PI / 180) *
318
318
             ((gdouble) (triangle->wheelradius -
319
319
                         triangle->triangleradius + 1) / 2 +
320
320
              triangle->triangleradius));
321
321
 
322
 
  atn = atan2 (x0, y0);
 
322
  atn = atan2 (y0, x0);
323
323
  if (atn < 0)
324
324
    atn = atn + 2 * G_PI;
325
325
 
326
326
  gimp_hsv_to_rgb4 (buf, atn / (2 * G_PI), 1, 1);
327
327
 
328
 
  col = GIMP_RGB_INTENSITY (buf[0], buf[1], buf[2]) > 127 ? 0 : 255;
 
328
  col = GIMP_RGB_LUMINANCE (buf[0], buf[1], buf[2]) > 127 ? 0 : 255;
329
329
 
330
330
  d = CLAMP (triangle->wheelradius / 16, 2, 4);
331
331
 
341
341
            }
342
342
          else
343
343
            {
344
 
              atn = atan2 (x, y);
 
344
              atn = atan2 (y, x);
345
345
              if (atn < 0)
346
346
                atn = atn + 2 * G_PI;
347
347
 
359
359
 
360
360
  /* marker in triangle */
361
361
 
362
 
  col = gimp_rgb_intensity (&selector->rgb) > 0.5 ? 0 : 255;
 
362
  col = gimp_rgb_luminance (&selector->rgb) > 0.5 ? 0 : 255;
363
363
 
364
364
  sat = triangle->oldsat = selector->hsv.s;
365
365
  val = triangle->oldval = selector->hsv.v;
382
382
            {
383
383
              if (SQR (x) + SQR (y) > SQR (triangle->triangleradius))
384
384
                {
385
 
                  atn = atan2 (x, y);
 
385
                  atn = atan2 (y, x);
386
386
                  if (atn < 0)
387
387
                    atn = atn + 2 * G_PI;
388
388
 
497
497
      x = event->button.x - (width - 1) / 2 - 1;
498
498
      y = - event->button.y + (height - 1) / 2 + 1;
499
499
      r = sqrt ((gdouble) (SQR (x) + SQR (y)));
500
 
      angle = ((gint) RINT (atan2 (x, y) / G_PI * 180) + 360 ) % 360;
 
500
      angle = ((gint) RINT (atan2 (y, x) / G_PI * 180) + 360 ) % 360;
501
501
 
502
502
      if ( /* r <= triangle->wheelradius  && */ r > triangle->triangleradius)
503
503
        triangle->mode = 1;  /* Dragging in the Ring */
513
513
      x = x - (width - 1) / 2 - 1;
514
514
      y = - y + (height - 1) / 2 + 1;
515
515
      r = sqrt ((gdouble) (SQR (x) + SQR (y)));
516
 
      angle = ((gint) RINT (atan2 (x, y) / G_PI * 180) + 360 ) % 360;
 
516
      angle = ((gint) RINT (atan2 (y, x) / G_PI * 180) + 360 ) % 360;
517
517
      break;
518
518
 
519
519
    case GDK_BUTTON_RELEASE:
542
542
    {
543
543
      hue = selector->hsv.h * 2 * G_PI;
544
544
 
545
 
      hx = sin (hue) * triangle->triangleradius;
546
 
      hy = cos (hue) * triangle->triangleradius;
547
 
      sx = sin (hue - 2 * G_PI / 3) * triangle->triangleradius;
548
 
      sy = cos (hue - 2 * G_PI / 3) * triangle->triangleradius;
549
 
      vx = sin (hue + 2 * G_PI / 3) * triangle->triangleradius;
550
 
      vy = cos (hue + 2 * G_PI / 3) * triangle->triangleradius;
 
545
      hx = cos (hue) * triangle->triangleradius;
 
546
      hy = sin (hue) * triangle->triangleradius;
 
547
      sx = cos (hue + 2 * G_PI / 3) * triangle->triangleradius;
 
548
      sy = sin (hue + 2 * G_PI / 3) * triangle->triangleradius;
 
549
      vx = cos (hue - 2 * G_PI / 3) * triangle->triangleradius;
 
550
      vy = sin (hue - 2 * G_PI / 3) * triangle->triangleradius;
551
551
 
552
552
      hue = selector->hsv.h * 360.0;
553
553