Debian Codegraph @

scene/resources/curve_texture.h

raw symbols SCIP
1 /**************************************************************************/
2 /* curve_texture.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/resources/texture.h"
34
35 class CurveTexture : public Texture2D {
36 GDCLASS(CurveTexture, Texture2D);
37 RES_BASE_EXTENSION("curvetex")
38 public:
39 enum TextureMode {
40 TEXTURE_MODE_RGB,
41 TEXTURE_MODE_RED,
42 };
43
44 private:
45 mutable RID _texture;
46 Ref<Curve> _curve;
47 int _width = 256;
48 int _current_width = 0;
49 TextureMode texture_mode = TEXTURE_MODE_RGB;
50 TextureMode _current_texture_mode = TEXTURE_MODE_RGB;
51
52 void _update();
53
54 protected:
55 static void _bind_methods();
56
57 public:
58 void set_width(int p_width);
59 int get_width() const override;
60
61 void set_texture_mode(TextureMode p_mode);
62 TextureMode get_texture_mode() const;
63
64 void ensure_default_setup(float p_min = 0, float p_max = 1);
65
66 void set_curve(Ref<Curve> p_curve);
67 Ref<Curve> get_curve() const;
68
69 virtual RID get_rid() const override;
70
71 virtual int get_height() const override { return 1; }
72 virtual bool has_alpha() const override { return false; }
73
74 ~CurveTexture();
75 };
76
77 VARIANT_ENUM_CAST(CurveTexture::TextureMode)
78
79 class CurveXYZTexture : public Texture2D {
80 GDCLASS(CurveXYZTexture, Texture2D);
81 RES_BASE_EXTENSION("curvetex")
82
83 private:
84 mutable RID _texture;
85 Ref<Curve> _curve_x;
86 Ref<Curve> _curve_y;
87 Ref<Curve> _curve_z;
88 int _width = 256;
89 int _current_width = 0;
90
91 void _update();
92
93 protected:
94 static void _bind_methods();
95
96 public:
97 void set_width(int p_width);
98 int get_width() const override;
99
100 void ensure_default_setup(float p_min = 0, float p_max = 1);
101
102 void set_curve_x(Ref<Curve> p_curve);
103 Ref<Curve> get_curve_x() const;
104
105 void set_curve_y(Ref<Curve> p_curve);
106 Ref<Curve> get_curve_y() const;
107
108 void set_curve_z(Ref<Curve> p_curve);
109 Ref<Curve> get_curve_z() const;
110
111 virtual RID get_rid() const override;
112
113 virtual int get_height() const override { return 1; }
114 virtual bool has_alpha() const override { return false; }
115
116 ~CurveXYZTexture();
117 };