Minor code clean-up. Started implementation of #92635 and #91396.

This commit is contained in:
Maurits Rijk 2003-03-18 20:35:32 +00:00
parent 3a2d973f01
commit c73726195e
11 changed files with 412 additions and 342 deletions

View File

@ -1,3 +1,13 @@
2003-03-18 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/imagemap/java.xpm
* plug-ins/imagemap/link.xpm
* plug-ins/imagemap/Makefile
* plug-ins/imagemap/imap_stock.[ch]: added 2 new icons.
* plug-ins/imagemap/imap_edit_area_info.c: start at implementing
enhancement #91396 and #92635.
2003-03-18 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch] (gimp_image_mask_translate)
@ -3213,6 +3223,11 @@
* app/text/gimptextlayer.c: changed accordingly.
2003-02-04 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/common/max_rgb.c: fixed bug with previewing images
with alpha channel.
2003-02-04 Sven Neumann <sven@gimp.org>
* app/widgets/gimpitemfactory.c (gimp_item_factory_item_key_press):

View File

@ -1,4 +1,4 @@
/* max_rgb.c -- This is a plug-in for the GIMP (1.0's API)
/* max_rgb.c -- This is a plug-in for the GIMP
* Author: Shuji Narazaki <narazaki@InetQ.or.jp>
* Time-stamp: <2000-02-08 16:26:24 yasuhiro>
* Version: 0.35
@ -41,7 +41,6 @@
/* Replace them with the right ones */
#define PLUG_IN_NAME "plug_in_max_rgb"
#define SHORT_NAME "max_rgb"
#define PROGRESS_UPDATE_NUM 100
static void query (void);
static void run (gchar *name,
@ -76,7 +75,7 @@ enum
typedef struct
{
gint max_p; /* gint, gdouble, and so on */
gint max_p;
} ValueType;
typedef struct
@ -212,7 +211,7 @@ max_rgb_func (guchar *src, guchar *dest, gint bpp, gpointer data)
dest[1] = (max_ch & (1 << 1)) ? max : 0;
dest[2] = (max_ch & (1 << 2)) ? max : 0;
if (param->has_alpha)
dest[3] = src[3];
dest[3] = *src;
}
static void
@ -223,31 +222,14 @@ main_function (GimpDrawable *drawable,
param.init_value = (pvals.max_p > 0) ? 0 : 255;
param.flag = (0 < pvals.max_p) ? 1 : -1;
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
if (preview_mode)
{
gint x, y;
gint bpp = preview->bpp;
param.has_alpha = FALSE; /* no alpha on preview */
for (y = 0; y < preview->height; y++)
{
guchar *src = preview->cache + y * preview->rowstride;
guchar *dest = preview->buffer + y * preview->rowstride;
for (x = 0; x < preview->width; x++)
{
max_rgb_func (src, dest, bpp, &param);
dest += bpp;
src += bpp;
}
}
gtk_widget_queue_draw (preview->widget);
gimp_fixme_preview_update (preview, max_rgb_func, &param);
}
else
{ /* normal mode */
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
gimp_progress_init ( _("Max RGB: Scanning..."));

View File

@ -30,8 +30,6 @@
* Algorithm fixes, V2.0 compatibility by David Hodson hodsond@ozemail.com.au
*/
/* add any necessary includes */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -41,11 +39,6 @@
#include <stdlib.h>
#include <math.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
@ -69,26 +62,11 @@ typedef enum
filter_edge_enhance
} FilterType;
/* preview stuff -- to be removed as soon as we have a real libgimp preview */
typedef struct
{
gint width;
gint height;
gint bpp;
gdouble scale;
guchar *bits;
} mwPreview;
#define PREVIEW_SIZE 100
static gint do_preview = TRUE;
static mwPreview *thePreview;
static GimpFixMePreview *preview;
static GtkWidget * mw_preview_new (GtkWidget *parent,
mwPreview *mwp);
static mwPreview * mw_preview_build (GimpDrawable *drw);
GimpDrawable *drawable);
/* function protos */
@ -100,7 +78,8 @@ static void run (gchar *name,
GimpParam **retvals);
static gint pluginCore (piArgs *argp);
static gint pluginCoreIA (piArgs *argp);
static gint pluginCoreIA (piArgs *argp,
GimpDrawable *drawable);
static void nlfilt_do_preview (GtkWidget *preview);
@ -177,7 +156,7 @@ run (gchar *name,
switch (param[0].data.d_int32)
{
GimpDrawable *drw;
GimpDrawable *drawable;
case GIMP_RUN_INTERACTIVE:
INIT_I18N_UI();
/* XXX: add code here for interactive running */
@ -187,10 +166,9 @@ run (gchar *name,
args.radius = (gdouble) 0.3;
args.filter = 0;
}
drw = gimp_drawable_get (args.drw);
thePreview = mw_preview_build (drw);
drawable = gimp_drawable_get (args.drw);
if (pluginCoreIA (&args) == -1)
if (pluginCoreIA (&args, drawable) == -1)
{
rvals[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
}
@ -337,7 +315,7 @@ nlfilt_double_adjustment_update (GtkAdjustment *adjustment,
}
static gint
pluginCoreIA (piArgs *argp)
pluginCoreIA (piArgs *argp, GimpDrawable *drawable)
{
gint retval = -1; /* default to error return */
GtkWidget *dlg;
@ -376,7 +354,7 @@ pluginCoreIA (piArgs *argp)
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = mw_preview_new (hbox, thePreview);
preview = mw_preview_new (hbox, drawable);
g_object_set_data (G_OBJECT (preview), "piArgs", argp);
nlfilt_do_preview (preview);
@ -432,50 +410,39 @@ pluginCoreIA (piArgs *argp)
gtk_main ();
gdk_flush ();
if (run_flag)
{
return pluginCore (argp);
}
else
{
return retval;
}
return (run_flag) ? pluginCore (argp) : retval;
}
static void
nlfilt_do_preview (GtkWidget *w)
{
static GtkWidget *theWidget = NULL;
piArgs *ap;
guchar *dst, *src0, *src1, *src2;
gint y, rowsize, filtno;
if (theWidget == NULL)
{
theWidget = w;
}
ap = g_object_get_data (G_OBJECT (preview->widget), "piArgs");
ap = g_object_get_data (G_OBJECT (theWidget), "piArgs");
rowsize = thePreview->width * thePreview->bpp;
rowsize = preview->width * preview->bpp;
filtno = nlfiltInit (ap->alpha, ap->radius, ap->filter);
src0 = thePreview->bits + thePreview->bpp;
src0 = preview->cache + preview->bpp;
src1 = src0 + rowsize;
src2 = src1 + rowsize;
dst = g_malloc (rowsize);
/* for preview, don't worry about edge effects */
for (y = 1; y < thePreview->height - 1; y++)
for (y = 1; y < preview->height - 1; y++)
{
nlfiltRow (src0, src1, src2, dst + thePreview->bpp,
thePreview->width - 2, thePreview->bpp, filtno);
gtk_preview_draw_row (GTK_PREVIEW (theWidget),
dst + thePreview->bpp, 1, y, thePreview->width - 2);
nlfiltRow (src0, src1, src2, dst + preview->bpp,
preview->width - 2, preview->bpp, filtno);
/*
We should probably fix the edges!
*/
gimp_fixme_preview_do_row (preview, y, preview->width, dst);
src0 = src1; src1 = src2; src2 += rowsize;
}
gtk_widget_queue_draw (theWidget);
gtk_widget_queue_draw (preview->widget);
g_free (dst);
}
@ -489,68 +456,9 @@ mw_preview_toggle_callback (GtkWidget *widget,
nlfilt_do_preview (NULL);
}
static mwPreview *
mw_preview_build_virgin (GimpDrawable *drw)
{
mwPreview *mwp;
mwp = g_new (mwPreview, 1);
if (drw->width > drw->height)
{
mwp->scale = (gdouble) drw->width / (gdouble) PREVIEW_SIZE;
mwp->width = PREVIEW_SIZE;
mwp->height = drw->height / mwp->scale;
}
else
{
mwp->scale = (gdouble) drw->height / (gdouble) PREVIEW_SIZE;
mwp->height = PREVIEW_SIZE;
mwp->width = drw->width / mwp->scale;
}
mwp->bpp = 3;
mwp->bits = NULL;
return mwp;
}
static mwPreview *
mw_preview_build (GimpDrawable *drw)
{
mwPreview *mwp;
gint x, y, b;
guchar *bc;
guchar *drwBits;
GimpPixelRgn pr;
mwp = mw_preview_build_virgin (drw);
gimp_pixel_rgn_init (&pr, drw, 0, 0, drw->width, drw->height, FALSE, FALSE);
drwBits = g_new (guchar, drw->width * drw->bpp);
bc = mwp->bits = g_new (guchar, mwp->width * mwp->height * mwp->bpp);
for (y = 0; y < mwp->height; y++)
{
gimp_pixel_rgn_get_row (&pr, drwBits, 0, (int)(y*mwp->scale), drw->width);
for (x = 0; x < mwp->width; x++)
{
for (b = 0; b < mwp->bpp; b++)
*bc++ = *(drwBits +
((gint) (x * mwp->scale) * drw->bpp) + b % drw->bpp);
}
}
g_free (drwBits);
return mwp;
}
static GtkWidget *
mw_preview_new (GtkWidget *parent,
mwPreview *mwp)
mw_preview_new (GtkWidget *parent, GimpDrawable *drawable)
{
GtkWidget *preview;
GtkWidget *frame;
GtkWidget *pframe;
GtkWidget *vbox;
@ -570,11 +478,10 @@ mw_preview_new (GtkWidget *parent,
gtk_frame_set_shadow_type (GTK_FRAME(pframe), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), pframe, FALSE, FALSE, 0);
gtk_widget_show (pframe);
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview), mwp->width, mwp->height);
gtk_container_add (GTK_CONTAINER (pframe), preview);
gtk_widget_show (preview);
preview = gimp_fixme_preview_new (drawable, FALSE);
gtk_container_add (GTK_CONTAINER (pframe), preview->widget);
gtk_widget_show (preview->widget);
button = gtk_check_button_new_with_mnemonic (_("_Do Preview"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), do_preview);
@ -585,7 +492,7 @@ mw_preview_new (GtkWidget *parent,
G_CALLBACK (mw_preview_toggle_callback),
&do_preview);
return preview;
return preview->widget;
}
/* pnmnlfilt.c - 4 in 1 (2 non-linear) filter
@ -642,11 +549,11 @@ mw_preview_new (GtkWidget *parent,
/* Compute the area of the intersection of a triangle */
/* and a rectangle */
gdouble triang_area(gdouble, gdouble, gdouble, gdouble, gdouble,
gdouble, gdouble, gdouble, gint);
gdouble rectang_area(gdouble, gdouble, gdouble, gdouble,
gdouble, gdouble, gdouble, gdouble);
gdouble hex_area(gdouble, gdouble, gdouble, gdouble, gdouble);
static gdouble triang_area(gdouble, gdouble, gdouble, gdouble, gdouble,
gdouble, gdouble, gdouble, gint);
static gdouble rectang_area(gdouble, gdouble, gdouble, gdouble,
gdouble, gdouble, gdouble, gdouble);
static gdouble hex_area(gdouble, gdouble, gdouble, gdouble, gdouble);
gint atfilt0(gint *p);
gint atfilt1(gint *p);
@ -1136,7 +1043,7 @@ atfilt5(gint *p) {
/* compute the area of overlap of a hexagon diameter d, */
/* centered at hx,hy, with a unit square of center sx,sy. */
gdouble
static gdouble
hex_area(gdouble sx, gdouble sy, gdouble hx, gdouble hy, gdouble d) {
gdouble hx0,hx1,hx2,hy0,hy1,hy2,hy3;
gdouble sx0,sx1,sy0,sy1;
@ -1163,7 +1070,7 @@ hex_area(gdouble sx, gdouble sy, gdouble hx, gdouble hy, gdouble d) {
triang_area(sx0,sy0,sx1,sy1,hx1,hy0,hx2,hy1,SE);
}
gdouble
static gdouble
triang_area(gdouble rx0, gdouble ry0, gdouble rx1, gdouble ry1, gdouble tx0,
gdouble ty0, gdouble tx1, gdouble ty1, gint tt) {
gdouble a,b,c,d;
@ -1240,7 +1147,7 @@ triang_area(gdouble rx0, gdouble ry0, gdouble rx1, gdouble ry1, gdouble tx0,
}
/* Compute rectangle area */
gdouble
static gdouble
rectang_area(gdouble rx0, gdouble ry0, gdouble rx1, gdouble ry1, gdouble tx0,
gdouble ty0, gdouble tx1, gdouble ty1) {
/* Compute overlapping box */

View File

@ -125,11 +125,6 @@ enum
/* Texture-flags */
#define GRADIENT 0x00000001
typedef struct
{
gdouble x, y, z, w;
} vector;
typedef struct
{
gshort xsize, ysize;
@ -138,38 +133,38 @@ typedef struct
typedef struct
{
gshort numcol;
gdouble pos[MAXCOLPERGRADIENT];
vector color[MAXCOLPERGRADIENT];
gshort numcol;
gdouble pos[MAXCOLPERGRADIENT];
GimpVector4 color[MAXCOLPERGRADIENT];
} gradient;
typedef struct
{
gint majtype;
gint type;
gulong flags;
vector color1, color2;
gradient gradient;
vector ambient, diffuse;
gdouble oscale;
vector scale, translate, rotate;
image image;
vector reflection;
vector refraction;
vector transparent;
gdouble ior;
vector phongcolor;
gdouble phongsize;
gdouble amount;
gdouble exp;
vector turbulence;
gint majtype;
gint type;
gulong flags;
GimpVector4 color1, color2;
gradient gradient;
GimpVector4 ambient, diffuse;
gdouble oscale;
GimpVector4 scale, translate, rotate;
image image;
GimpVector4 reflection;
GimpVector4 refraction;
GimpVector4 transparent;
gdouble ior;
GimpVector4 phongcolor;
gdouble phongsize;
gdouble amount;
gdouble exp;
GimpVector4 turbulence;
} texture;
typedef struct
{
gshort type;
gdouble density;
vector color;
GimpVector4 color;
gdouble turbulence;
} atmos;
@ -186,48 +181,48 @@ typedef struct
typedef struct
{
common com;
vector a, b, c;
GimpVector4 a, b, c;
} triangle;
typedef struct
{
common com;
vector a;
gdouble b, r;
common com;
GimpVector4 a;
gdouble b, r;
} disc;
typedef struct
{
common com;
vector a;
gdouble r;
common com;
GimpVector4 a;
gdouble r;
} sphere;
typedef struct
{
common com;
vector a, b, c;
common com;
GimpVector4 a, b, c;
} cylinder;
typedef struct
{
common com;
vector a;
gdouble b;
common com;
GimpVector4 a;
gdouble b;
} plane;
typedef struct
{
common com;
vector color;
vector a;
common com;
GimpVector4 color;
GimpVector4 a;
} light;
typedef struct
{
vector v1, v2;
gshort inside;
gdouble ior;
GimpVector4 v1, v2;
gshort inside;
gdouble ior;
} ray;
typedef union
@ -258,7 +253,7 @@ struct world_t
struct camera_t
{
vector location, lookat, up, right;
GimpVector4 location, lookat, up, right;
short type;
double fov, tilt;
};
@ -299,14 +294,15 @@ struct
settings = { 1, 1, 1 };
static inline void vset (vector *v, gdouble a, gdouble b, gdouble c);
static inline void vset (GimpVector4 *v, gdouble a, gdouble b, gdouble c);
static void restartrender (void);
static void drawcolor1 (GtkWidget *widget);
static void drawcolor2 (GtkWidget *widget);
static void render (void);
static void realrender (GimpDrawable *drawable);
static void fileselect (gint);
static gint traceray (ray * r, vector * col, gint level, gdouble imp);
static gint traceray (ray * r, GimpVector4 * col, gint level,
gdouble imp);
static gdouble turbulence (gdouble *point, gdouble lofreq, gdouble hifreq);
@ -482,38 +478,27 @@ struct camera_t camera;
struct world_t world;
static inline void
vcopy (vector * a, vector * b)
vcopy (GimpVector4 *a, GimpVector4 *b)
{
a->x = b->x;
a->y = b->y;
a->z = b->z;
a->w = b->w;
*a = *b;
}
static inline void
vcross (vector * r, vector * a, vector * b)
vcross (GimpVector4 *r, GimpVector4 *a, GimpVector4 *b)
{
vector t;
t.x = a->y * b->z - a->z * b->y;
t.y = -(a->x * b->z - a->z * b->x);
t.z = a->x * b->y - a->y * b->x;
vcopy (r, &t);
r->x = a->y * b->z - a->z * b->y;
r->y = -(a->x * b->z - a->z * b->x);
r->z = a->x * b->y - a->y * b->x;
}
static inline gdouble
vdot (vector * a, vector * b)
vdot (GimpVector4 *a, GimpVector4 *b)
{
gdouble s;
s = a->x * b->x;
s += a->y * b->y;
s += a->z * b->z;
return s;
return a->x * b->x + a->y * b->y + a->z * b->z;
}
static inline gdouble
vdist (vector * a, vector * b)
vdist (GimpVector4 *a, GimpVector4 *b)
{
gdouble x, y, z;
@ -525,28 +510,24 @@ vdist (vector * a, vector * b)
}
static inline gdouble
vlen (vector * a)
vlen (GimpVector4 *a)
{
gdouble l;
l = sqrt (a->x * a->x + a->y * a->y + a->z * a->z);
return l;
return sqrt (a->x * a->x + a->y * a->y + a->z * a->z);
}
static inline void
vnorm (vector * a, gdouble v)
vnorm (GimpVector4 *a, gdouble v)
{
gdouble d;
d = sqrt (a->x * a->x + a->y * a->y + a->z * a->z);
d = vlen (a);
a->x *= v / d;
a->y *= v / d;
a->z *= v / d;
}
static inline void
vrotate (vector * axis, gdouble ang, vector * vector)
vrotate (GimpVector4 *axis, gdouble ang, GimpVector4 *vector)
{
gdouble rad = ang / 180.0 * G_PI;
gdouble ax = vector->x;
@ -574,7 +555,7 @@ vrotate (vector * axis, gdouble ang, vector * vector)
}
static inline void
vset (vector * v, gdouble a, gdouble b, gdouble c)
vset (GimpVector4 *v, gdouble a, gdouble b, gdouble c)
{
v->x = a;
v->y = b;
@ -583,7 +564,7 @@ vset (vector * v, gdouble a, gdouble b, gdouble c)
}
static inline void
vcset (vector * v, gdouble a, gdouble b, gdouble c, gdouble d)
vcset (GimpVector4 *v, gdouble a, gdouble b, gdouble c, gdouble d)
{
v->x = a;
v->y = b;
@ -592,9 +573,9 @@ vcset (vector * v, gdouble a, gdouble b, gdouble c, gdouble d)
}
static inline void
vvrotate (vector * p, vector * rot)
vvrotate (GimpVector4 *p, GimpVector4 *rot)
{
vector axis;
GimpVector4 axis;
if (rot->x != 0.0)
{
@ -614,7 +595,7 @@ vvrotate (vector * p, vector * rot)
}
static inline void
vsub (vector * a, vector * b)
vsub (GimpVector4 *a, GimpVector4 *b)
{
a->x -= b->x;
a->y -= b->y;
@ -623,7 +604,7 @@ vsub (vector * a, vector * b)
}
static inline void
vadd (vector * a, vector * b)
vadd (GimpVector4 *a, GimpVector4 *b)
{
a->x += b->x;
a->y += b->y;
@ -632,7 +613,7 @@ vadd (vector * a, vector * b)
}
static inline void
vneg (vector * a)
vneg (GimpVector4 *a)
{
a->x = -a->x;
a->y = -a->y;
@ -641,7 +622,7 @@ vneg (vector * a)
}
static inline void
vmul (vector * v, gdouble a)
vmul (GimpVector4 *v, gdouble a)
{
v->x *= a;
v->y *= a;
@ -650,7 +631,7 @@ vmul (vector * v, gdouble a)
}
static inline void
vvmul (vector * a, vector * b)
vvmul (GimpVector4 *a, GimpVector4 *b)
{
a->x *= b->x;
a->y *= b->y;
@ -659,7 +640,7 @@ vvmul (vector * a, vector * b)
}
static inline void
vvdiv (vector * a, vector * b)
vvdiv (GimpVector4 *a, GimpVector4 *b)
{
a->x /= b->x;
a->y /= b->y;
@ -667,7 +648,7 @@ vvdiv (vector * a, vector * b)
}
static void
vmix (vector * r, vector * a, vector * b, gdouble v)
vmix (GimpVector4 *r, GimpVector4 *a, GimpVector4 *b, gdouble v)
{
gdouble i = 1.0 - v;
@ -678,7 +659,7 @@ vmix (vector * r, vector * a, vector * b, gdouble v)
}
static double
vmax (vector * a)
vmax (GimpVector4 *a)
{
gdouble max = fabs (a->x);
@ -694,7 +675,7 @@ vmax (vector * a)
#if 0
static void
vavg (vector * a)
vavg (GimpVector4 * a)
{
gdouble s;
@ -703,9 +684,8 @@ vavg (vector * a)
}
#endif
static void
trianglenormal (vector * n, gdouble *t, triangle * tri)
trianglenormal (GimpVector4 * n, gdouble *t, triangle * tri)
{
triangle tmp;
vcopy (&tmp.b, &tri->b);
@ -721,7 +701,7 @@ trianglenormal (vector * n, gdouble *t, triangle * tri)
static gdouble
checkdisc (ray * r, disc * disc)
{
vector p, *v = &disc->a;
GimpVector4 p, *v = &disc->a;
gdouble t, d;
gdouble i, j, k;
@ -747,7 +727,7 @@ checkdisc (ray * r, disc * disc)
static gdouble
checksphere (ray * r, sphere * sphere)
{
vector cendir, rdir;
GimpVector4 cendir, rdir;
gdouble dirproj, cdlensq;
gdouble linear, constant, rsq, quadratic, discriminant;
gdouble smallzero, solmin, solmax, tolerance = 0.001;
@ -826,7 +806,7 @@ checkcylinder (ray * r, cylinder * cylinder)
static gdouble
checkplane (ray * r, plane * plane)
{
vector *v = &plane->a;
GimpVector4 *v = &plane->a;
gdouble t;
gdouble i, j, k;
@ -843,10 +823,10 @@ checkplane (ray * r, plane * plane)
static gdouble
checktri (ray * r, triangle * tri)
{
vector ed1, ed2;
vector tvec, pvec, qvec;
GimpVector4 ed1, ed2;
GimpVector4 tvec, pvec, qvec;
gdouble det, idet, t, u, v;
vector *orig, dir;
GimpVector4 *orig, dir;
orig = &r->v1;
dir = r->v2;
@ -886,7 +866,7 @@ checktri (ray * r, triangle * tri)
}
static void
transformpoint (vector * p, texture * t)
transformpoint (GimpVector4 * p, texture * t)
{
gdouble point[3], f;
@ -907,16 +887,15 @@ transformpoint (vector * p, texture * t)
p->y += t->turbulence.y * f;
p->z += t->turbulence.z * f;
}
}
static void
checker (vector * q, vector * col, texture * t)
checker (GimpVector4 *q, GimpVector4 *col, texture *t)
{
gint c = 0;
vector p;
GimpVector4 p;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
vmul (&p, 0.25);
@ -939,32 +918,23 @@ checker (vector * q, vector * col, texture * t)
if ((p.z - (gint) p.z) < 0.5)
c ^= 1;
if (c)
{
vcopy (col, &t->color1);
}
else
{
vcopy (col, &t->color2);
}
*col = (c) ? t->color1 : t->color2;
}
static void
gradcolor (vector * col, gradient * t, gdouble val)
gradcolor (GimpVector4 *col, gradient *t, gdouble val)
{
gint i;
gdouble d;
vector tmpcol;
GimpVector4 tmpcol;
val = CLAMP (val, 0.0, 1.0);
if (val < 0.0)
val = 0.0;
if (val > 1.0)
val = 1.0;
for (i = 0; i < t->numcol; i++)
{
if (t->pos[i] == val)
{
vcopy (col, &t->color[i]);
*col = t->color[i];
return;
}
if (t->pos[i] > val)
@ -984,12 +954,12 @@ gradcolor (vector * col, gradient * t, gdouble val)
}
static void
marble (vector * q, vector * col, texture * t)
marble (GimpVector4 *q, GimpVector4 *col, texture *t)
{
gdouble f;
vector p;
GimpVector4 p;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
f = sin (p.x * 4) / 2 + 0.5;
@ -1002,12 +972,12 @@ marble (vector * q, vector * col, texture * t)
}
static void
lizard (vector * q, vector * col, texture * t)
lizard (GimpVector4 *q, GimpVector4 *col, texture *t)
{
gdouble f;
vector p;
GimpVector4 p;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
f = fabs (sin (p.x * 4));
@ -1020,16 +990,15 @@ lizard (vector * q, vector * col, texture * t)
gradcolor (col, &t->gradient, f);
else
vmix (col, &t->color1, &t->color2, f);
}
static void
wood (vector * q, vector * col, texture * t)
wood (GimpVector4 *q, GimpVector4 *col, texture *t)
{
gdouble f;
vector p;
GimpVector4 p;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
f = fabs (p.x);
@ -1044,12 +1013,12 @@ wood (vector * q, vector * col, texture * t)
}
static void
spiral (vector * q, vector * col, texture * t)
spiral (GimpVector4 *q, GimpVector4 *col, texture *t)
{
gdouble f;
vector p;
GimpVector4 p;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
f = fabs (atan2 (p.x, p.z) / G_PI / 2 + p.y + 99999);
@ -1064,12 +1033,12 @@ spiral (vector * q, vector * col, texture * t)
}
static void
spots (vector * q, vector * col, texture * t)
spots (GimpVector4 *q, GimpVector4 *col, texture *t)
{
gdouble f;
vector p, r;
GimpVector4 p, r;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
p.x += 10000.0;
@ -1079,10 +1048,7 @@ spots (vector * q, vector * col, texture * t)
vset (&r, (gint) (p.x + 0.5), (gint) (p.y + 0.5), (gint) (p.z + 0.5));
f = vdist (&p, &r);
f = cos (f * G_PI);
if (f < 0.0)
f = 0.0;
else if (f > 1.0)
f = 1.0;
f = CLAMP (f, 0.0, 1.0);
f = pow (f, t->exp);
if (t->flags & GRADIENT)
@ -1092,12 +1058,12 @@ spots (vector * q, vector * col, texture * t)
}
static void
perlin (vector * q, vector * col, texture * t)
perlin (GimpVector4 * q, GimpVector4 * col, texture * t)
{
gdouble f, point[3];
vector p;
GimpVector4 p;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
point[0] = p.x;
@ -1115,13 +1081,13 @@ perlin (vector * q, vector * col, texture * t)
}
static void
imagepixel (vector * q, vector * col, texture * t)
imagepixel (GimpVector4 * q, GimpVector4 * col, texture * t)
{
vector p;
GimpVector4 p;
gint x, y;
guchar *rgb;
vcopy (&p, q);
p = *q;
transformpoint (&p, t);
x = (p.x * t->image.xsize);
@ -1135,11 +1101,11 @@ imagepixel (vector * q, vector * col, texture * t)
}
static void
objcolor (vector * col, vector * p, common * obj)
objcolor (GimpVector4 *col, GimpVector4 *p, common *obj)
{
gint i;
texture *t;
vector tmpcol;
GimpVector4 tmpcol;
vcset (col, 0, 0, 0, 0);
@ -1202,11 +1168,10 @@ objcolor (vector * col, vector * p, common * obj)
{
fprintf (stderr, "Warning: object %p has no textures\n", obj);
}
}
static void
objnormal (vector * res, common * obj, vector * p)
objnormal (GimpVector4 *res, common *obj, GimpVector4 *p)
{
gint i;
@ -1237,8 +1202,8 @@ objnormal (vector * res, common * obj, vector * p)
for (i = 0; i < obj->numnormal; i++)
{
gint k;
vector tmpcol[6];
vector q[6], nres;
GimpVector4 tmpcol[6];
GimpVector4 q[6], nres;
texture *t = &obj->normal[i];
gdouble nstep = 0.1;
@ -1320,14 +1285,14 @@ objnormal (vector * res, common * obj, vector * p)
*/
static void
calclight (vector * col, vector * point, common * obj)
calclight (GimpVector4 * col, GimpVector4 * point, common * obj)
{
gint i, j;
ray r;
gdouble d, b, a;
vector lcol;
vector norm;
vector pcol;
GimpVector4 lcol;
GimpVector4 norm;
GimpVector4 pcol;
vcset (col, 0, 0, 0, 0);
@ -1400,14 +1365,14 @@ calclight (vector * col, vector * point, common * obj)
}
static void
calcphong (common * obj, ray * r2, vector * col)
calcphong (common * obj, ray * r2, GimpVector4 * col)
{
gint i, j, o;
ray r;
gdouble d, b;
vector lcol;
vector norm;
vector pcol;
GimpVector4 lcol;
GimpVector4 norm;
GimpVector4 pcol;
gdouble ps;
vcopy (&pcol, col);
@ -1458,14 +1423,14 @@ calcphong (common * obj, ray * r2, vector * col)
}
static int
traceray (ray * r, vector * col, gint level, gdouble imp)
traceray (ray * r, GimpVector4 * col, gint level, gdouble imp)
{
gint i, b = -1;
gdouble t = -1.0, min = 0.0;
gint type = -1;
common *obj, *bobj = NULL;
gint hits = 0;
vector p;
GimpVector4 p;
if ((level == 0) || (imp < 0.005))
{
@ -1529,7 +1494,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
if (world.flags & SMARTAMBIENT)
{
gdouble ambient = 0.3 * exp (-min / world.smartambient);
vector lcol;
GimpVector4 lcol;
objcolor (&lcol, &p, bobj);
vmul (&lcol, ambient);
vadd (col, &lcol);
@ -1543,7 +1508,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
|| (bobj->texture[i].type == PHONG)))
{
vector refcol, norm, ocol;
GimpVector4 refcol, norm, ocol;
ray ref;
objcolor (&ocol, &p, bobj);
@ -1587,7 +1552,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
if ((world.quality >= 5) && (col->w < 1.0))
{
vector refcol;
GimpVector4 refcol;
ray ref;
vcopy (&ref.v1, &p);
@ -1604,7 +1569,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
if ((world.quality >= 5) && (bobj->texture[i].type == TRANSPARENT))
{
vector refcol;
GimpVector4 refcol;
ray ref;
vcopy (&ref.v1, &p);
@ -1624,7 +1589,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
if ((world.quality >= 5) && (bobj->texture[i].type == SMOKE))
{
vector smcol, raydir, norm;
GimpVector4 smcol, raydir, norm;
double tran;
ray ref;
@ -1649,7 +1614,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
if ((world.quality >= 5) && (bobj->texture[i].type == REFRACTION))
{
vector refcol, norm, tmpv;
GimpVector4 refcol, norm, tmpv;
ray ref;
double c1, c2, n1, n2, n;
@ -1720,7 +1685,7 @@ traceray (ray * r, vector * col, gint level, gdouble imp)
for (i = 0; i < world.numatmos; i++)
{
vector tmpcol;
GimpVector4 tmpcol;
if (world.atmos[i].type == FOG)
{
gdouble v, pt[3];
@ -1880,7 +1845,6 @@ setvals (texture * t)
noupdate = FALSE;
}
static void
selectitem (GtkTreeSelection *treeselection,
gpointer data)
@ -2398,10 +2362,10 @@ color1_changed (GimpColorButton *button,
gpointer data)
{
texture *t = currenttexture ();
if (!t)
return;
gimp_color_button_get_color (button, (GimpRGB *) &t->color1);
if (t)
{
gimp_color_button_get_color (button, (GimpRGB *) &t->color1);
}
}
static void
@ -2409,10 +2373,10 @@ color2_changed (GimpColorButton *button,
gpointer data)
{
texture *t = currenttexture ();
if (!t)
return;
gimp_color_button_get_color (button, (GimpRGB *) &t->color2);
if (t)
{
gimp_color_button_get_color (button, (GimpRGB *) &t->color2);
}
}
static void
@ -2455,7 +2419,6 @@ drawcolor2 (GtkWidget *w)
(const GimpRGB *) &t->color2);
}
static gboolean do_run = FALSE;
static void
@ -2954,7 +2917,7 @@ render (void)
{
gint x, y, p;
ray r;
vector col;
GimpVector4 col;
gint hit;
gint tx, ty;
guchar *dest_row;
@ -3038,11 +3001,11 @@ render (void)
}
static void
realrender (GimpDrawable * drawable)
realrender (GimpDrawable *drawable)
{
gint x, y;
ray r;
vector rcol;
GimpVector4 rcol;
gint tx, ty;
gint x1, y1, x2, y2;
guchar *dest;
@ -3110,7 +3073,7 @@ realrender (GimpDrawable * drawable)
g_free (ibuffer);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
}
static void

View File

@ -10,6 +10,8 @@ EXTRA_DIST = \
coord.xpm \
dimension.xpm \
grid.xpm \
java.xpm \
link.xpm \
map_info.xpm \
polygon.xpm \
rectangle.xpm \

View File

@ -34,6 +34,7 @@
#include "imap_default_dialog.h"
#include "imap_edit_area_info.h"
#include "imap_main.h"
#include "imap_stock.h"
#include "imap_table.h"
#include "libgimp/stdplugins-intl.h"
@ -158,6 +159,26 @@ select_email_cb(GtkWidget *widget, AreaInfoDialog_t *param)
set_url(widget, param, "mailto:");
}
static void
append_page (GtkWidget *notebook, GtkWidget *page, const gchar *icon_name,
const gchar *label_name)
{
GtkWidget *hbox, *icon, *label;
hbox = gtk_hbox_new(FALSE, 1);
gtk_widget_show(hbox);
icon = gtk_image_new_from_stock (icon_name, GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (hbox), icon);
gtk_widget_show (icon);
label = gtk_label_new_with_mnemonic(label_name);
gtk_container_add (GTK_CONTAINER (hbox), label);
gtk_widget_show (label);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, hbox);
}
static void
create_link_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
{
@ -251,8 +272,7 @@ create_link_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
label = create_label_in_table(table, 9, 0, _("ALT te_xt: (optional)"));
dialog->comment = create_entry_in_table(table, label, 10, 0);
label = gtk_label_new_with_mnemonic(_("_Link"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
append_page (notebook, table, IMAP_STOCK_LINK, _("_Link"));
}
static void
@ -298,8 +318,8 @@ create_info_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
dialog->infotab = obj->class->create_info_widget(frame);
label = gtk_label_new_with_mnemonic(gettext(obj->class->name));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
append_page (notebook, vbox, obj->class->get_stock_icon_name (),
gettext (obj->class->name));
}
static void
@ -328,8 +348,7 @@ create_java_script_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
label = create_label_in_table(table, 9, 0, "on_Blur (HTML 4.0):");
dialog->blur = create_entry_in_table(table, label, 10, 0);
label = gtk_label_new_with_mnemonic(_("_JavaScript"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
append_page (notebook, vbox, IMAP_STOCK_JAVA, _("_JavaScript"));
}
static gboolean

View File

@ -32,6 +32,8 @@
#include "coord.xpm"
#include "dimension.xpm"
#include "grid.xpm"
#include "java.xpm"
#include "link.xpm"
#include "map_info.xpm"
#include "polygon.xpm"
#include "rectangle.xpm"
@ -69,6 +71,8 @@ init_stock_icons(void)
add_stock_icon(factory, IMAP_STOCK_COORD, (const char**) coord_xpm);
add_stock_icon(factory, IMAP_STOCK_DIMENSION, (const char**) dimension_xpm);
add_stock_icon(factory, IMAP_STOCK_GRID, (const char**) grid_xpm);
add_stock_icon(factory, IMAP_STOCK_JAVA, (const char**) java_xpm);
add_stock_icon(factory, IMAP_STOCK_LINK, (const char**) link_xpm);
add_stock_icon(factory, IMAP_STOCK_MAP_INFO, (const char**) map_info_xpm);
add_stock_icon(factory, IMAP_STOCK_POLYGON, (const char**) polygon_xpm);
add_stock_icon(factory, IMAP_STOCK_RECTANGLE, (const char**) rectangle_xpm);

View File

@ -29,6 +29,8 @@
#define IMAP_STOCK_COORD "imap_coord"
#define IMAP_STOCK_DIMENSION "imap_dimension"
#define IMAP_STOCK_GRID "imap_grid"
#define IMAP_STOCK_JAVA "imap_java"
#define IMAP_STOCK_LINK "imap_link"
#define IMAP_STOCK_MAP_INFO "imap-map-info"
#define IMAP_STOCK_POLYGON "imap_polygon"
#define IMAP_STOCK_RECTANGLE "imap_rectangle"

147
plug-ins/imagemap/java.xpm Normal file
View File

@ -0,0 +1,147 @@
/* XPM */
static char *java_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 125 2",
" c black",
". c #010000",
"X c #010101",
"o c #020101",
"O c #060606",
"+ c #0E0000",
"@ c #0A0A0A",
"# c #0C0C0C",
"$ c #130404",
"% c #160F0F",
"& c #111111",
"* c #181717",
"= c #1A1A1A",
"- c #271C1C",
"; c #2F1D1D",
": c #202020",
"> c #242525",
", c #3B3A3A",
"< c #3C3C3C",
"1 c #492020",
"2 c #5E2E2E",
"3 c #424242",
"4 c #434343",
"5 c #464646",
"6 c #474747",
"7 c #4A4A4A",
"8 c #4D4D4D",
"9 c #4E4E4E",
"0 c #515151",
"q c #555555",
"w c #585858",
"e c #5C5C5C",
"r c #626262",
"t c #636363",
"y c #646464",
"u c #6D6161",
"i c #696A6A",
"p c #6C6C6C",
"a c #6D6D6D",
"s c #707070",
"d c #717171",
"f c #727272",
"g c #747474",
"h c #767676",
"j c #777777",
"k c #787878",
"l c #797979",
"z c #7B7B7B",
"x c #7C7C7C",
"c c #7D7D7D",
"v c #7E7E7E",
"b c #7F7F7F",
"n c #841414",
"m c #A81515",
"M c #AA1515",
"N c #A52D2D",
"B c #8F6363",
"V c #AA7575",
"C c #C50000",
"Z c #F50101",
"A c #F42525",
"S c #FF2626",
"D c #C57777",
"F c #ED4545",
"G c #F67A7A",
"H c #808080",
"J c #818181",
"K c #828282",
"L c #848484",
"P c #868686",
"I c #878787",
"U c #898989",
"Y c #8D8D8D",
"T c #8F8F8F",
"R c #909090",
"E c #919191",
"W c #949494",
"Q c #959595",
"! c #979797",
"~ c #989898",
"^ c #9A9A9A",
"/ c #9B9B9B",
"( c #9C9C9C",
") c #9D9D9D",
"_ c #9E9E9E",
"` c #A0A0A0",
"' c #A3A3A3",
"] c #A5A5A5",
"[ c #A9A9A9",
"{ c #ABABAB",
"} c #ACACAC",
"| c #ADADAD",
" . c #AEAEAE",
".. c #AFAFAF",
"X. c #B0B0B0",
"o. c #B3B3B3",
"O. c #B4B4B4",
"+. c #B5B6B6",
"@. c #B7B7B7",
"#. c #B9B9B9",
"$. c #BABABA",
"%. c #BBBBBB",
"&. c #BCBCBC",
"*. c #BDBDBD",
"=. c #BEBEBE",
"-. c #BFBFBF",
";. c #C8B9B9",
":. c #CCBDBD",
">. c #C0C0C0",
",. c #C3C3C3",
"<. c #D6CECE",
"1. c #D5D5D5",
"2. c #E1E1E1",
"3. c #E7E7E7",
"4. c #E9E7E7",
"5. c #E8E8E8",
"6. c #EEEBEB",
"7. c #EDEDED",
"8. c #EFEFEF",
"9. c #F8F8F8",
"0. c #FAFAFA",
"q. c #FEFEFE",
"w. c #FEFFFF",
"e. c gray100",
"r. c None",
/* pixels */
"r.r.r.r.r.r.*.@.y P *.r.r.r.r.r.",
"r.r.r.r.r.r.*.P = 5 O.r.r.r.r.r.",
"r.r.r.r.r.r.} < X = ` r.*.} O.r.",
"r.r.r.r.r.*.U # X @ g *.$.l l -.",
"r.r.r.r.r.O.7 X X X 9 O.*.p 5 } ",
"r.r.r.r.r.! * - 1 $ > ) *.r O d ",
"r.r.r.r.*.d ; D F n % x $.e = x ",
"r.r.*.} J , 2 G S C + q ! d U [ ",
"r.r.} p q i B A Z m u 9 t [ r.r.",
"%.O.x 5 R @.;.N m V 4.x l *.r.r.",
"} y : 3 L ,.9.<.:.6.e.) ~ *.r.r.",
"*.p # & 0 2.e.e.e.e.e.' ) *.r.r.",
"$.P 3 w x 8.e.6.4.9.e.' ~ *.r.r.",
"r.%.! J R 4.} b l Y 1.' ) *.r.r.",
"r.r.@.) b R l R ! J J U ' *.r.r.",
"r.r.r.X.p g } *.r.$.U f X.r.r.r."
};

View File

@ -0,0 +1,32 @@
/* XPM */
static char *link_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 10 1",
" c black",
". c navy",
"X c blue",
"o c #008000",
"O c #008080",
"+ c #808080",
"@ c #C0C0C0",
"# c #D4D0C8",
"$ c gray100",
"% c None",
/* pixels */
"%%%@+@@+@%%%%%%%",
"%%+@O@##o %%%%%%",
"%@#@$#oooo %%%%%",
"+@X$@XXXXoo@%%%%",
"@X@##.ooXoo %%%%",
"@X#oooo.O.o %%%%",
"+XX#oooooXX %%%%",
"@XXXXooooOX %%%%",
"@.XXXooooX.@%%%%",
"% XXX . %%",
"%% . @$@$ $#$# %",
"%%% @ # ",
"%%% $ + @@@ + $ ",
"%%% # # ",
"%%%% @$@# #@$# %",
"%%%%% % %%"
};

View File

@ -42,10 +42,7 @@ GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
MSGMERGE = msgmerge
DEFS = @DEFS@
CFLAGS = @CFLAGS@