-
Notifications
You must be signed in to change notification settings - Fork 1
/
CircleWithConeTexture2D.h
133 lines (104 loc) · 3.37 KB
/
CircleWithConeTexture2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//
// Created by Daniel on 2024-03-06.
//
#ifndef CIRCLEWITHCONETEXTURE2D_H
#define CIRCLEWITHCONETEXTURE2D_H
#include "scene/resources/texture.h"
class CircleWithConeTexture2D : public Texture2D {
GDCLASS(CircleWithConeTexture2D, Texture2D);
public:
private:
Ref<Image> use_image;
Vector<uint8_t> image_data;
mutable RID texture;
int width = 64;
int height = 64;
Vector2 cone_from = Vector2(0,0);
Vector2 cone_to = Vector2(1, 0);
float cone_angle = 0.5;
float cone_smoothing_angle = 0.1;
float circle_end_radius = 0.5;
float circle_start_radius = 0.5;
float circle_max_radius = 500.0;
float circle_max_smoothing = 0.5;
Color color_inside = Color(0.0,0.0,0.0,1.0);
Color color_outside = Color(1.0,1.0,1.0,1.0);
float _get_color_at(int x, int y) const;
bool update_pending = false;
void _queue_update();
void _update();
protected:
static void _bind_methods();
public:
void set_width(int p_width);
virtual int get_width() const override;
void set_height(int p_height);
virtual int get_height() const override;
void set_cone_from(Vector2 p_cone_from) {
cone_from = p_cone_from;
_queue_update();
emit_changed();
}
Vector2 get_cone_from() { return cone_from;}
void set_cone_to(Vector2 p_cone_to) {
cone_to = p_cone_to;
_queue_update();
emit_changed();
}
Vector2 get_cone_to() { return cone_to; }
void set_cone_angle(float p_angle) {
cone_angle = p_angle;
_queue_update();
emit_changed();
}
virtual float get_cone_angle() { return cone_angle; }
void set_cone_smoothing_angle(float p_angle) {
cone_smoothing_angle = p_angle;
_queue_update();
emit_changed();
}
virtual float get_cone_smoothing_angle() { return cone_smoothing_angle; }
void set_circle_start_radius(float p_radius) {
circle_start_radius = p_radius;
_queue_update();
emit_changed();
}
virtual float get_circle_start_radius() {return circle_start_radius;}
void set_circle_end_radius(float p_radius) {
circle_end_radius = p_radius;
_queue_update();
emit_changed();
}
virtual float get_circle_end_radius() {return circle_end_radius;}
void set_circle_max_radius(float p_radius) {
circle_max_radius = p_radius;
_queue_update();
emit_changed();
}
virtual float get_circle_max_radius() {return circle_max_radius;}
void set_circle_max_smoothing(float p_radius) {
circle_max_smoothing = p_radius;
_queue_update();
emit_changed();
}
virtual float get_circle_max_smoothing() {return circle_max_smoothing;}
void set_color_inside(Color p_angle) {
color_inside = p_angle;
_queue_update();
emit_changed();
}
virtual Color get_color_inside() { return color_inside; }
void set_color_outside(Color p_angle) {
color_outside = p_angle;
_queue_update();
emit_changed();
}
virtual Color get_color_outside() { return color_outside; }
virtual RID get_rid() const override;
virtual bool has_alpha() const override { return true; }
virtual Ref<Image> get_image() const override;
void update_now();
CircleWithConeTexture2D();
virtual ~CircleWithConeTexture2D();
};
#endif //CIRCLEWITHCONETEXTURE2D_H