diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-05-07 12:20:32 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-07 12:20:32 -0300 |
commit | 863781dd3c1ed114bab5d4d491271e3ad8ee211b (patch) | |
tree | 68097e0706bccfd559f932e86445b280f393eb40 /core/image.cpp | |
parent | b89e354ce634884ee2f5839577667b4e835f97c8 (diff) | |
parent | 97485c8df03af04e8459f3ca72c3d60f6985daa1 (diff) | |
download | redot-engine-863781dd3c1ed114bab5d4d491271e3ad8ee211b.tar.gz |
Merge pull request #18505 from AlexHolly/image-point2-helper
add Point2 helper for Image.get_pixel and Image.set_pixel
Diffstat (limited to 'core/image.cpp')
-rw-r--r-- | core/image.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/image.cpp b/core/image.cpp index 8cd2562bcb..0e1841b021 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1910,6 +1910,10 @@ void Image::unlock() { write_lock = PoolVector<uint8_t>::Write(); } +Color Image::get_pixelv(const Point2 &p_src) const { + return get_pixel(p_src.x, p_src.y); +} + Color Image::get_pixel(int p_x, int p_y) const { uint8_t *ptr = write_lock.ptr(); @@ -2056,6 +2060,10 @@ Color Image::get_pixel(int p_x, int p_y) const { return Color(); } +void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) { + return set_pixel(p_dst.x, p_dst.y, p_color); +} + void Image::set_pixel(int p_x, int p_y, const Color &p_color) { uint8_t *ptr = write_lock.ptr(); @@ -2287,8 +2295,10 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("lock"), &Image::lock); ClassDB::bind_method(D_METHOD("unlock"), &Image::unlock); - ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel); + ClassDB::bind_method(D_METHOD("get_pixelv", "src"), &Image::get_pixelv); ClassDB::bind_method(D_METHOD("get_pixel", "x", "y"), &Image::get_pixel); + ClassDB::bind_method(D_METHOD("set_pixelv", "dst", "color"), &Image::set_pixelv); + ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel); ClassDB::bind_method(D_METHOD("load_png_from_buffer", "buffer"), &Image::load_png_from_buffer); ClassDB::bind_method(D_METHOD("load_jpg_from_buffer", "buffer"), &Image::load_jpg_from_buffer); |