diff options
author | 2019-10-07 03:56:16 +0200 | |
---|---|---|
committer | 2019-10-07 03:56:16 +0200 | |
commit | c9510db551893775d3233340dd114d971e24323a (patch) | |
tree | a48fe9009c0fa604ea5e861ee3a8aa35ae3d64c3 /wgpu/src/transformation.rs | |
parent | 70c17b053b10741f6018b2559bb46c5f289cadb9 (diff) | |
download | iced-c9510db551893775d3233340dd114d971e24323a.tar.gz iced-c9510db551893775d3233340dd114d971e24323a.tar.bz2 iced-c9510db551893775d3233340dd114d971e24323a.zip |
Render colored quads
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/transformation.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/wgpu/src/transformation.rs b/wgpu/src/transformation.rs new file mode 100644 index 00000000..1101e135 --- /dev/null +++ b/wgpu/src/transformation.rs @@ -0,0 +1,30 @@ +#[derive(Debug, Clone, Copy)] +pub struct Transformation([f32; 16]); + +impl Transformation { + #[rustfmt::skip] + pub fn identity() -> Self { + Transformation([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + ]) + } + + #[rustfmt::skip] + pub fn orthographic(width: u16, height: u16) -> Self { + Transformation([ + 2.0 / width as f32, 0.0, 0.0, 0.0, + 0.0, 2.0 / height as f32, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + -1.0, -1.0, 0.0, 1.0, + ]) + } +} + +impl From<Transformation> for [f32; 16] { + fn from(transformation: Transformation) -> [f32; 16] { + transformation.0 + } +} |