1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __GIMP_CURVE_H__
19 #define __GIMP_CURVE_H__
20 
21 
22 #include "gimpdata.h"
23 
24 
25 #define GIMP_TYPE_CURVE            (gimp_curve_get_type ())
26 #define GIMP_CURVE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CURVE, GimpCurve))
27 #define GIMP_CURVE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CURVE, GimpCurveClass))
28 #define GIMP_IS_CURVE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CURVE))
29 #define GIMP_IS_CURVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CURVE))
30 #define GIMP_CURVE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CURVE, GimpCurveClass))
31 
32 
33 typedef struct _GimpCurvePoint GimpCurvePoint;
34 typedef struct _GimpCurveClass GimpCurveClass;
35 
36 struct _GimpCurvePoint
37 {
38   gdouble            x;
39   gdouble            y;
40 
41   GimpCurvePointType type;
42 };
43 
44 struct _GimpCurve
45 {
46   GimpData        parent_instance;
47 
48   GimpCurveType   curve_type;
49 
50   gint            n_points;
51   GimpCurvePoint *points;
52 
53   gint            n_samples;
54   gdouble        *samples;
55 
56   gboolean        identity;  /* whether the curve is an identity mapping */
57 };
58 
59 struct _GimpCurveClass
60 {
61   GimpDataClass  parent_class;
62 };
63 
64 
65 GType                gimp_curve_get_type          (void) G_GNUC_CONST;
66 
67 GimpData           * gimp_curve_new               (const gchar        *name);
68 GimpData           * gimp_curve_get_standard      (void);
69 
70 void                 gimp_curve_reset             (GimpCurve          *curve,
71                                                    gboolean            reset_type);
72 
73 void                 gimp_curve_set_curve_type    (GimpCurve          *curve,
74                                                    GimpCurveType       curve_type);
75 GimpCurveType        gimp_curve_get_curve_type    (GimpCurve          *curve);
76 
77 gint                 gimp_curve_get_n_points      (GimpCurve          *curve);
78 
79 void                 gimp_curve_set_n_samples     (GimpCurve          *curve,
80                                                    gint                n_samples);
81 gint                 gimp_curve_get_n_samples     (GimpCurve          *curve);
82 
83 gint                 gimp_curve_get_point_at      (GimpCurve          *curve,
84                                                    gdouble             x);
85 gint                 gimp_curve_get_closest_point (GimpCurve          *curve,
86                                                    gdouble             x,
87                                                    gdouble             y,
88                                                    gdouble             max_distance);
89 
90 gint                 gimp_curve_add_point         (GimpCurve          *curve,
91                                                    gdouble             x,
92                                                    gdouble             y);
93 void                 gimp_curve_delete_point      (GimpCurve          *curve,
94                                                    gint                point);
95 void                 gimp_curve_set_point         (GimpCurve          *curve,
96                                                    gint                point,
97                                                    gdouble             x,
98                                                    gdouble             y);
99 void                 gimp_curve_move_point        (GimpCurve          *curve,
100                                                    gint                point,
101                                                    gdouble             y);
102 void                 gimp_curve_get_point         (GimpCurve          *curve,
103                                                    gint                point,
104                                                    gdouble            *x,
105                                                    gdouble            *y);
106 void                 gimp_curve_set_point_type    (GimpCurve          *curve,
107                                                    gint                point,
108                                                    GimpCurvePointType  type);
109 GimpCurvePointType   gimp_curve_get_point_type    (GimpCurve          *curve,
110                                                    gint                point);
111 void                 gimp_curve_clear_points      (GimpCurve          *curve);
112 
113 void                 gimp_curve_set_curve         (GimpCurve          *curve,
114                                                    gdouble             x,
115                                                    gdouble             y);
116 
117 gboolean             gimp_curve_is_identity       (GimpCurve          *curve);
118 
119 void                 gimp_curve_get_uchar         (GimpCurve          *curve,
120                                                    gint                n_samples,
121                                                    guchar             *samples);
122 
123 
124 #endif /* __GIMP_CURVE_H__ */
125