docs/bevy/release-content/migration-guides/border_radius.md 1.3 K · 50 lines · raw · history

1 ---
2 title: "BorderRadius_and_ResolvedBorderRadius_fields_are_now_2d"
3 pull_requests: [24779]
4 ---
5
6 In order to support elliptical nodes, the fields of `BorderRadius` are now `CornerRadius`s and the fields of `ResolvedBorderRadius` are now `Vec2`s.
7
8 Before:
9
10 ```rust
11 BorderRadius {
12 pub top_left: px(10.),
13 pub top_right: percent(20.),
14 pub bottom_right: zero(),
15 pub bottom_left: vh(5.),
16 }
17 ```
18
19 After:
20
21 ```rust
22 BorderRadius {
23 pub top_left: CornerRadius::circular(px(10.)),
24 pub top_right: CornerRadius::circular(percent(20.)),
25 pub bottom_right: CornerRadius::circular(zero()),
26 pub bottom_left: CornerRadius::circular(vh(5.)),
27 }
28 ```
29
30 `CornerRadius` implements `From<Val>`, so you can also use `into`:
31
32 ```rust
33 BorderRadius {
34 pub top_left: px(10.).into(),
35 pub top_right: percent(20.).into(),
36 pub bottom_right: zero().into(),
37 pub bottom_left: vh(5.).into(),
38 }
39 ```
40
41 Circular corner radius is represented by setting either `CornerRadius::x` or `CornerRadius::y` to `Val::Auto`.
42
43 The `BorderRadius` constructor and update functions are no longer `const`. This is so that the parameters can take any type implementing `Into<CornerRadius>`:
44
45 ```rust
46 let n = BorderRadius::top_right(vh(10.));
47 let m = BorderRadius::top_right([px(10.), px(20.)]);
48 ```
49
50 `BorderRadius::resolve_single_corner` has been removed, use `CornerRadius::resolve` instead.