Animated transforms on hover
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use glam::{Mat4, Vec2, Vec3};
|
||||
use vulkano::buffer::BufferContents;
|
||||
|
||||
// binary compatible mat4 which could be transparently used by vulkano BufferContents
|
||||
@@ -6,13 +7,20 @@ use vulkano::buffer::BufferContents;
|
||||
pub struct WMat4(pub [f32; 16]);
|
||||
|
||||
impl WMat4 {
|
||||
pub fn from_glam(mat: &glam::Mat4) -> WMat4 {
|
||||
pub fn from_glam(mat: &Mat4) -> WMat4 {
|
||||
WMat4(*mat.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for WMat4 {
|
||||
fn default() -> Self {
|
||||
Self(*glam::Mat4::IDENTITY.as_ref())
|
||||
Self(*Mat4::IDENTITY.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
// works just like CSS transform-origin 50% 50%
|
||||
pub fn centered_matrix(box_size: Vec2, input: &Mat4) -> Mat4 {
|
||||
Mat4::from_translation(Vec3::new(box_size.x / 2.0, box_size.y / 2.0, 0.0))
|
||||
* *input
|
||||
* Mat4::from_translation(Vec3::new(-box_size.x / 2.0, -box_size.y / 2.0, 0.0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user