~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to plug-ins/common/polar-coords.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 * E-mail: bless@ai-lab.fh-furtwangen.de
12
12
 * WWW:    www.ai-lab.fh-furtwangen.de/~bless
13
13
 *
14
 
 * This program is free software; you can redistribute it and/or modify
 
14
 * This program is free software: you can redistribute it and/or modify
15
15
 * it under the terms of the GNU General Public License as published by
16
 
 * the Free Software Foundation; either version 2 of the License, or
 
16
 * the Free Software Foundation; either version 3 of the License, or
17
17
 * (at your option) any later version.
18
18
 *
19
19
 * This program is distributed in the hope that it will be useful,
22
22
 * GNU General Public License for more details.
23
23
 *
24
24
 * You should have received a copy of the GNU General Public License
25
 
 * along with this program; if not, write to the Free Software
26
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
25
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
26
 */
28
27
 
29
28
 
70
69
 
71
70
#define PLUG_IN_PROC    "plug-in-polar-coords"
72
71
#define PLUG_IN_BINARY  "polar-coords"
 
72
#define PLUG_IN_ROLE    "gimp-polar-coords"
73
73
#define PLUG_IN_VERSION "July 1997, 0.5"
74
74
 
75
75
#define SCALE_WIDTH     200
142
142
{
143
143
  static const GimpParamDef args[] =
144
144
  {
145
 
    { GIMP_PDB_INT32,    "run-mode",  "Interactive, non-interactive" },
146
 
    { GIMP_PDB_IMAGE,    "image",     "Input image"                  },
147
 
    { GIMP_PDB_DRAWABLE, "drawable",  "Input drawable"               },
148
 
    { GIMP_PDB_FLOAT,    "circle",    "Circle depth in %"            },
149
 
    { GIMP_PDB_FLOAT,    "angle",     "Offset angle"                 },
150
 
    { GIMP_PDB_INT32,    "backwards", "Map backwards?"               },
151
 
    { GIMP_PDB_INT32,    "inverse",   "Map from top?"                },
152
 
    { GIMP_PDB_INT32,    "polrec",    "Polar to rectangular?"        }
 
145
    { GIMP_PDB_INT32,    "run-mode",  "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
 
146
    { GIMP_PDB_IMAGE,    "image",     "Input image"                          },
 
147
    { GIMP_PDB_DRAWABLE, "drawable",  "Input drawable"                       },
 
148
    { GIMP_PDB_FLOAT,    "circle",    "Circle depth in %"                    },
 
149
    { GIMP_PDB_FLOAT,    "angle",     "Offset angle"                         },
 
150
    { GIMP_PDB_INT32,    "backwards", "Map backwards { TRUE, FALSE }"        },
 
151
    { GIMP_PDB_INT32,    "inverse",   "Map from top { TRUE, FALSE }"         },
 
152
    { GIMP_PDB_INT32,    "polrec",    "Polar to rectangular { TRUE, FALSE }" }
153
153
  };
154
154
 
155
155
  gimp_install_procedure (PLUG_IN_PROC,
203
203
  img_height    = gimp_drawable_height (drawable->drawable_id);
204
204
  img_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
205
205
 
206
 
  gimp_drawable_mask_bounds (drawable->drawable_id,
207
 
                             &sel_x1, &sel_y1, &sel_x2, &sel_y2);
 
206
  if (! gimp_drawable_mask_intersect (drawable->drawable_id,
 
207
                                      &sel_x1, &sel_y1, &sel_width, &sel_height))
 
208
    return;
208
209
 
209
210
  /* Calculate scaling parameters */
210
211
 
211
 
  sel_width  = sel_x2 - sel_x1;
212
 
  sel_height = sel_y2 - sel_y1;
 
212
  sel_x2 = sel_x1 + sel_width;
 
213
  sel_y2 = sel_y1 + sel_height;
213
214
 
214
215
  cen_x = (double) (sel_x1 + sel_x2 - 1) / 2.0;
215
216
  cen_y = (double) (sel_y1 + sel_y2 - 1) / 2.0;
386
387
 
387
388
  /* initialize */
388
389
 
389
 
  phi = 0.0;
390
 
  r   = 0.0;
391
 
 
 
390
  phi    = 0.0;
392
391
  x1     = 0;
393
392
  y1     = 0;
394
393
  x2     = img_width;
437
436
            }
438
437
        }
439
438
 
440
 
      r   = sqrt (SQR (wx - cen_x) + SQR (wy - cen_y));
 
439
      r = sqrt (SQR (wx - cen_x) + SQR (wy - cen_y));
441
440
 
442
441
      if (wx != cen_x)
443
442
        {
589
588
 
590
589
  gimp_ui_init (PLUG_IN_BINARY, TRUE);
591
590
 
592
 
  dialog = gimp_dialog_new (_("Polar Coordinates"), PLUG_IN_BINARY,
 
591
  dialog = gimp_dialog_new (_("Polar Coordinates"), PLUG_IN_ROLE,
593
592
                            NULL, 0,
594
593
                            gimp_standard_help_func, PLUG_IN_PROC,
595
594
 
605
604
 
606
605
  gimp_window_set_transient (GTK_WINDOW (dialog));
607
606
 
608
 
  main_vbox = gtk_vbox_new (FALSE, 12);
 
607
  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
609
608
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
610
 
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
 
609
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
 
610
                      main_vbox, TRUE, TRUE, 0);
611
611
  gtk_widget_show (main_vbox);
612
612
 
613
613
  /* Preview */
652
652
                            preview);
653
653
 
654
654
  /* togglebuttons for backwards, top, polar->rectangular */
655
 
  hbox = gtk_hbox_new (TRUE, 6);
 
655
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 
656
  gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
656
657
  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
657
658
 
658
659
  toggle = gtk_check_button_new_with_mnemonic (_("_Map backwards"));