mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-20 11:37:14 +00:00
fafae590e3
2001-01-22 Sven Neumann <sven@gimp.org> * configure.in * app/Makefile.am * app/tools/Makefile.am: moved all tool sources to app/tools * app/app_procs.c * app/brush_select.c * app/commands.c * app/context_manager.c * app/convert.c * app/cursorutil.c * app/devices.c * app/disp_callbacks.c * app/edit_selection.c * app/gdisplay.c * app/gimage.c * app/gimage_mask.c * app/gimpbrush.c * app/gimpbrushgenerated.c * app/gimpbrushpipe.c * app/gimpdnd.c * app/gimprc.c * app/global_edit.c * app/info_window.c * app/interface.c * app/menus.c * app/path.c * app/paths_dialog.c * app/paths_dialogP.h * app/scale.c * app/scroll.c * app/undo.c * app/pdb/color_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * po/POTFILES.in * tools/kernelgen.c * tools/pdbgen/Makefile.am * tools/pdbgen/enums.pl * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly
128 lines
3.3 KiB
C
128 lines
3.3 KiB
C
/* The GIMP -- an image manipulation program
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
*
|
|
* kernel_gen -- Copyright (C) 2000 Sven Neumann <sven@gimp.org>
|
|
* Simple hack to create subsampling kernels for the brushes
|
|
* as used in app/paint_core.c.
|
|
* If you want to play with it, change some of the #defines at the
|
|
* top and copy the output to apps/tools/paint_core_kernels.h.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (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
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
#define STEPS 64
|
|
#define KERNEL_WIDTH 3 /* changing these makes no sense */
|
|
#define KERNEL_HEIGHT 3 /* changing these makes no sense */
|
|
#define SUBSAMPLE 4
|
|
#define THRESHOLD 0.25 /* try to change this one */
|
|
|
|
#define SQR(x) ((x) * (x))
|
|
|
|
static void
|
|
create_kernel (double x,
|
|
double y)
|
|
{
|
|
double value[KERNEL_WIDTH][KERNEL_HEIGHT];
|
|
double dist_x;
|
|
double dist_y;
|
|
double sum;
|
|
double w;
|
|
int i, j;
|
|
|
|
memset (value, 0, KERNEL_WIDTH * KERNEL_HEIGHT * sizeof (double));
|
|
sum = 0.0;
|
|
|
|
x += 1.0;
|
|
y += 1.0;
|
|
|
|
for (j = 0; j < STEPS * KERNEL_HEIGHT; j++)
|
|
{
|
|
dist_y = y - (((double)j + 0.5) / (double)STEPS);
|
|
|
|
for (i = 0; i < STEPS * KERNEL_WIDTH; i++)
|
|
{
|
|
dist_x = x - (((double)i + 0.5) / (double)STEPS);
|
|
|
|
/* I've tried to use a gauss function here instead of a
|
|
threshold, but the result was not that impressive. */
|
|
w = (SQR (dist_x) + SQR (dist_y)) < THRESHOLD ? 1.0 : 0.0;
|
|
|
|
value[i / STEPS][j / STEPS] += w;
|
|
sum += w;
|
|
}
|
|
}
|
|
|
|
for (j = 0; j < KERNEL_HEIGHT; j++)
|
|
{
|
|
for (i = 0; i < KERNEL_WIDTH; i++)
|
|
{
|
|
w = 256.0 * (value[i][j] / sum);
|
|
printf (" %3d,", (int)w);
|
|
}
|
|
}
|
|
}
|
|
|
|
int
|
|
main (int argc,
|
|
char **argv)
|
|
{
|
|
int i, j;
|
|
double x, y;
|
|
|
|
printf ("/* paint_core_kernels.h\n"
|
|
" *\n"
|
|
" * This file was generated using kernelgen as found in the tools dir.\n");
|
|
printf (" * (threshold = %g)\n", THRESHOLD);
|
|
printf (" */\n\n");
|
|
printf ("#define KERNEL_WIDTH %d\n", KERNEL_WIDTH);
|
|
printf ("#define KERNEL_HEIGHT %d\n", KERNEL_HEIGHT);
|
|
printf ("#define SUBSAMPLE %d\n", SUBSAMPLE);
|
|
printf ("\n\n");
|
|
printf ("/* Brush pixel subsampling kernels */\n");
|
|
printf ("static const int subsample[%d][%d][%d] = {\n",
|
|
SUBSAMPLE + 1, SUBSAMPLE + 1, KERNEL_WIDTH * KERNEL_HEIGHT);
|
|
|
|
for (j = 0; j <= SUBSAMPLE; j++)
|
|
{
|
|
y = (double)j / (double)(SUBSAMPLE);
|
|
|
|
printf (" {\n");
|
|
|
|
for (i = 0; i <= SUBSAMPLE; i++)
|
|
{
|
|
x = (double)i / (double)(SUBSAMPLE);
|
|
|
|
printf (" {");
|
|
create_kernel (x, y);
|
|
printf (" }%c\n", i < SUBSAMPLE ? ',' : ' ');
|
|
}
|
|
|
|
printf (" }%c\n", j < SUBSAMPLE ? ',' : ' ');
|
|
}
|
|
|
|
printf ("};\n");
|
|
|
|
exit (0);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|