Simplify pick_rounded_rect (#15065)
# Objective Simplify `pick_rounded_rect` with multiple `if` statements to make it more readable and efficient([Godbolt link](https://godbolt.org/z/W5vPEvT5c)). Co-authored-by: WX\shixi <shixi1@cnwxsoft.com>
This commit is contained in:
parent
7b217a976c
commit
bca228fdaa
@ -352,12 +352,12 @@ pub(crate) fn pick_rounded_rect(
|
|||||||
size: Vec2,
|
size: Vec2,
|
||||||
border_radius: ResolvedBorderRadius,
|
border_radius: ResolvedBorderRadius,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let s = point.signum();
|
let [top, bottom] = if point.x < 0. {
|
||||||
let r = (border_radius.top_left * (1. - s.x) * (1. - s.y)
|
[border_radius.top_left, border_radius.bottom_left]
|
||||||
+ border_radius.top_right * (1. + s.x) * (1. - s.y)
|
} else {
|
||||||
+ border_radius.bottom_right * (1. + s.x) * (1. + s.y)
|
[border_radius.top_right, border_radius.bottom_right]
|
||||||
+ border_radius.bottom_left * (1. - s.x) * (1. + s.y))
|
};
|
||||||
/ 4.;
|
let r = if point.y < 0. { top } else { bottom };
|
||||||
|
|
||||||
let corner_to_point = point.abs() - 0.5 * size;
|
let corner_to_point = point.abs() - 0.5 * size;
|
||||||
let q = corner_to_point + r;
|
let q = corner_to_point + r;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user