aboutsummaryrefslogtreecommitdiff
path: root/game/addons/zylann.hterrain/native/src/image_utils.h
blob: 5cbe399e1235c8157aab098861c0a971dd7bc66e (plain) (blame)
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
#ifndef IMAGE_UTILS_H
#define IMAGE_UTILS_H

#include <core/Godot.hpp>
#include <gen/Image.hpp>
#include <gen/Reference.hpp>
#include <vector>

namespace godot {

class ImageUtils : public Reference {
    GODOT_CLASS(ImageUtils, Reference)
public:
    static void _register_methods();

    ImageUtils();
    ~ImageUtils();

    void _init();

    Vector2 get_red_range(Ref<Image> image_ref, Rect2 rect) const;
    float get_red_sum(Ref<Image> image_ref, Rect2 rect) const;
    float get_red_sum_weighted(Ref<Image> image_ref, Ref<Image> brush_ref, Vector2 p_pos, float factor) const;
    void add_red_brush(Ref<Image> image_ref, Ref<Image> brush_ref, Vector2 p_pos, float factor) const;
    void lerp_channel_brush(Ref<Image> image_ref, Ref<Image> brush_ref, Vector2 p_pos, float factor, float target_value, int channel) const;
    void lerp_color_brush(Ref<Image> image_ref, Ref<Image> brush_ref, Vector2 p_pos, float factor, Color target_value) const;
    float generate_gaussian_brush(Ref<Image> image_ref) const;
    void blur_red_brush(Ref<Image> image_ref, Ref<Image> brush_ref, Vector2 p_pos, float factor);
    void paint_indexed_splat(Ref<Image> index_map_ref, Ref<Image> weight_map_ref, Ref<Image> brush_ref, Vector2 p_pos, int texture_index, float factor);
    //void erode_red_brush(Ref<Image> image_ref, Ref<Image> brush_ref, Vector2 p_pos, float factor);

private:
    std::vector<float> _blur_buffer;
};

} // namespace godot

#endif // IMAGE_UTILS_H