3D perspective working.
This commit is contained in:
parent
8fcc0bee65
commit
2b8db432be
|
@ -1,7 +1,7 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
use zero_ui::prelude::*;
|
||||
|
||||
use zero_ui_view_prebuilt as zero_ui_view;
|
||||
// use zero_ui_view_prebuilt as zero_ui_view;
|
||||
|
||||
fn main() {
|
||||
examples_util::print_info();
|
||||
|
@ -42,7 +42,10 @@ fn app_main() {
|
|||
spacing = 25;
|
||||
children_align = Align::TOP;
|
||||
children = ui_vec![
|
||||
transformed_3d("Rotate Y:45º, X:10º", rotate_y(45.deg()).rotate_x(10.deg())),
|
||||
transformed_3d("Rotate Y:45º (.5, .5)", rotate_y(45.deg()), Point::center()),
|
||||
transformed_3d("Rotate Y:45º (0., 0.)", rotate_y(45.deg()), Point::top_left()),
|
||||
transformed_3d("Rotate Y:45º (1., 1.)", rotate_y(45.deg()), Point::bottom_right()),
|
||||
|
||||
// transformed_3d("Translate-Z 30", translate_z(30)),
|
||||
];
|
||||
},
|
||||
|
@ -76,7 +79,7 @@ fn transformed(label: impl Into<Txt>, transform: Transform) -> impl UiNode {
|
|||
border = 2, (colors::GRAY, BorderStyle::Dashed);
|
||||
}
|
||||
}
|
||||
fn transformed_3d(label: impl Into<Txt>, transform: Transform) -> impl UiNode {
|
||||
fn transformed_3d(label: impl Into<Txt>, transform: Transform, origin: Point) -> impl UiNode {
|
||||
Container! {
|
||||
child = Container! {
|
||||
#[easing(300.ms())]
|
||||
|
@ -84,16 +87,14 @@ fn transformed_3d(label: impl Into<Txt>, transform: Transform) -> impl UiNode {
|
|||
child = Text!(label.into());
|
||||
background_color = color_scheme_map(colors::BROWN.with_alpha(80.pct()), hex!(#EF6950).with_alpha(80.pct()));
|
||||
padding = 10;
|
||||
id = "3d-child";
|
||||
|
||||
|
||||
when *#is_hovered {
|
||||
transform = Transform::identity();
|
||||
}
|
||||
};
|
||||
|
||||
id = "3d-parent";
|
||||
perspective = 800;
|
||||
perspective = 200;
|
||||
perspective_origin = origin;
|
||||
transform_style = TransformStyle::Preserve3D;
|
||||
border = 2, (colors::GRAY, BorderStyle::Dashed);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue