1 /* LIBGIMP - The GIMP Library
2 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
4 * This library is free software: you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <https://www.gnu.org/licenses/>.
21 #include <glib-object.h>
23 #include "gimpcolortypes.h"
31 * @short_description: Definitions and Functions relating to HSV colors.
33 * Definitions and Functions relating to HSV colors.
41 static GimpHSV
* gimp_hsv_copy (const GimpHSV
*hsv
);
45 gimp_hsv_get_type (void)
47 static GType hsv_type
= 0;
50 hsv_type
= g_boxed_type_register_static ("GimpHSV",
51 (GBoxedCopyFunc
) gimp_hsv_copy
,
52 (GBoxedFreeFunc
) g_free
);
58 gimp_hsv_copy (const GimpHSV
*hsv
)
60 return g_memdup (hsv
, sizeof (GimpHSV
));
67 gimp_hsv_set (GimpHSV
*hsv
,
72 g_return_if_fail (hsv
!= NULL
);
80 gimp_hsv_clamp (GimpHSV
*hsv
)
82 g_return_if_fail (hsv
!= NULL
);
84 hsv
->h
-= (gint
) hsv
->h
;
89 hsv
->s
= CLAMP (hsv
->s
, 0.0, 1.0);
90 hsv
->v
= CLAMP (hsv
->v
, 0.0, 1.0);
91 hsv
->a
= CLAMP (hsv
->a
, 0.0, 1.0);
95 gimp_hsva_set (GimpHSV
*hsva
,
101 g_return_if_fail (hsva
!= NULL
);