Fixing wrong blending rect methods
Using Color.blend function instead of custom code Fixed clang_format Removed unnecessary help
This commit is contained in:
parent
2e84b7b916
commit
b211a86ebe
|
@ -2442,14 +2442,13 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
|
||||||
int dst_y = dest_rect.position.y + i;
|
int dst_y = dest_rect.position.y + i;
|
||||||
|
|
||||||
Color sc = img->get_pixel(src_x, src_y);
|
Color sc = img->get_pixel(src_x, src_y);
|
||||||
|
if (sc.a != 0) {
|
||||||
Color dc = get_pixel(dst_x, dst_y);
|
Color dc = get_pixel(dst_x, dst_y);
|
||||||
dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
|
dc = dc.blend(sc);
|
||||||
dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
|
|
||||||
dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
|
|
||||||
dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
|
|
||||||
set_pixel(dst_x, dst_y, dc);
|
set_pixel(dst_x, dst_y, dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
|
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
|
||||||
|
@ -2498,15 +2497,14 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
|
||||||
int dst_y = dest_rect.position.y + i;
|
int dst_y = dest_rect.position.y + i;
|
||||||
|
|
||||||
Color sc = img->get_pixel(src_x, src_y);
|
Color sc = img->get_pixel(src_x, src_y);
|
||||||
|
if (sc.a != 0) {
|
||||||
Color dc = get_pixel(dst_x, dst_y);
|
Color dc = get_pixel(dst_x, dst_y);
|
||||||
dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
|
dc = dc.blend(sc);
|
||||||
dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
|
|
||||||
dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
|
|
||||||
dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
|
|
||||||
set_pixel(dst_x, dst_y, dc);
|
set_pixel(dst_x, dst_y, dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::fill(const Color &c) {
|
void Image::fill(const Color &c) {
|
||||||
|
|
Loading…
Reference in New Issue