Several types functions were using the wording "float" historically to mean double-precision, e.g. the float array type (which was in fact a double array). Or the scanner function gimp_scanner_parse_float() was in fact returning a double value. What if we wanted someday to actually add float (usually this naming means in C the single-precision IEEE 754 floating point representation) support? How would we name this? Now technically it's not entirely wrong (a double is still a floating point). So I've been wondering if that is because maybe we never planned to have float and double precision may be good enough for all usage in a plug-in API (which doesn't have to be as generic so the higher precision is enough)? But how can we be sure? Also we already had some functions using the wording double (e.g. gimp_procedure_add_double_argument()), so let's just go the safe route and use the accurate wording. The additional change in PDB is internal, but there too, I was also finding very confusing that we were naming double-precision float as 'float' type. So I took the opportunity to update this. It doesn't change any signature. In fact the whole commit doesn't change any type or code logic, only naming, except for one bug fix in the middle which I encountered while renaming: in gimp_scanner_parse_deprecated_color(), I discovered a hidden bug in scanning (color-hsv*) values, which was mistakenly using a double type for an array of float.
372 lines
8.3 KiB
Text
372 lines
8.3 KiB
Text
# GIMP - The GNU Image Manipulation Program
|
|
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
# 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 3 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
sub image_grid_get_spacing {
|
|
$blurb = "Gets the spacing of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure retrieves the horizontal and vertical spacing of an image's grid.
|
|
It takes the image as parameter.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'xspacing', type => 'double', void_ret => 1,
|
|
desc => "The image's grid horizontal spacing" },
|
|
{ name => 'yspacing', type => 'double', void_ret => 1,
|
|
desc => "The image's grid vertical spacing" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_get (grid,
|
|
"xspacing", &xspacing,
|
|
"yspacing", &yspacing,
|
|
NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_set_spacing {
|
|
$blurb = "Sets the spacing of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure sets the horizontal and vertical spacing of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' },
|
|
{ name => 'xspacing', type => 'double',
|
|
desc => "The image's grid horizontal spacing" },
|
|
{ name => 'yspacing', type => 'double',
|
|
desc => "The image's grid vertical spacing" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<CODE
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_set (grid,
|
|
"xspacing", xspacing,
|
|
"yspacing", yspacing,
|
|
NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_get_offset {
|
|
$blurb = "Gets the offset of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure retrieves the horizontal and vertical offset of an image's grid.
|
|
It takes the image as parameter.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'xoffset', type => 'double', void_ret => 1,
|
|
desc => "The image's grid horizontal offset" },
|
|
{ name => 'yoffset', type => 'double', void_ret => 1,
|
|
desc => "The image's grid vertical offset" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_get (grid,
|
|
"xoffset", &xoffset,
|
|
"yoffset", &yoffset,
|
|
NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_set_offset {
|
|
$blurb = "Sets the offset of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure sets the horizontal and vertical offset of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' },
|
|
{ name => 'xoffset', type => 'double',
|
|
desc => "The image's grid horizontal offset" },
|
|
{ name => 'yoffset', type => 'double',
|
|
desc => "The image's grid vertical offset" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<CODE
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_set (grid,
|
|
"xoffset", xoffset,
|
|
"yoffset", yoffset,
|
|
NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_get_foreground_color {
|
|
$blurb = "Sets the foreground color of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure gets the foreground color of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'fgcolor', type => 'geglcolor', has_alpha => 1,
|
|
desc => "The image's grid foreground color" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
fgcolor = gegl_color_duplicate (grid->fgcolor);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_set_foreground_color {
|
|
$blurb = "Gets the foreground color of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure sets the foreground color of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' },
|
|
{ name => 'fgcolor', type => 'geglcolor', has_alpha => 1,
|
|
desc => "The new foreground color" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_set (grid, "fgcolor", fgcolor, NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_get_background_color {
|
|
$blurb = "Sets the background color of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure gets the background color of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'bgcolor', type => 'geglcolor', has_alpha => 1,
|
|
desc => "The image's grid background color" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
bgcolor = gegl_color_duplicate (grid->bgcolor);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_set_background_color {
|
|
$blurb = "Gets the background color of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure sets the background color of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' },
|
|
{ name => 'bgcolor', type => 'geglcolor', has_alpha => 1,
|
|
desc => "The new background color" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_set (grid, "bgcolor", bgcolor, NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_get_style {
|
|
$blurb = "Gets the style of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure retrieves the style of an image's grid.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'style', type => 'enum GimpGridStyle',
|
|
desc => "The image's grid style" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<CODE
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_get (grid, "style", &style, NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_grid_set_style {
|
|
$blurb = "Sets the style unit of an image's grid.";
|
|
|
|
$help = <<HELP;
|
|
This procedure sets the style of an image's grid.
|
|
It takes the image and the new style as parameters.
|
|
HELP
|
|
|
|
&sylvain_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' },
|
|
{ name => 'style', type => 'enum GimpGridStyle',
|
|
desc => "The image's grid style" }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<CODE
|
|
{
|
|
GimpGrid *grid = gimp_image_get_grid (image);
|
|
|
|
if (grid)
|
|
g_object_set (grid, "style", style, NULL);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
|
|
@headers = qw("core/gimpimage-grid.h" "core/gimpgrid.h"
|
|
"libgimpbase/gimpbaseenums.h");
|
|
|
|
@procs = qw(image_grid_get_spacing image_grid_set_spacing
|
|
image_grid_get_offset image_grid_set_offset
|
|
image_grid_get_foreground_color image_grid_set_foreground_color
|
|
image_grid_get_background_color image_grid_set_background_color
|
|
image_grid_get_style image_grid_set_style);
|
|
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
$desc = 'Image grid procedures';
|
|
$doc_title = 'gimpimagegrid';
|
|
$doc_short_desc = "Functions manuipulating an image's grid.";
|
|
$doc_long_desc = "Functions manuipulating an image's grid.";
|
|
|
|
1;
|