removed the colored vertex and combined into one. Half fixed texturing. Fully fixed images and compute swapping
This commit is contained in:
@@ -3,7 +3,9 @@ use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Sprite {
|
||||
|
||||
pub vertices: [(f32, f32); 6],
|
||||
pub ti_position: [(f32, f32); 6],
|
||||
|
||||
position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
@@ -37,6 +39,14 @@ impl Sprite {
|
||||
],
|
||||
|
||||
position: position,
|
||||
ti_position: [
|
||||
(-1.0, -1.0), // top left
|
||||
(-1.0, 1.0), // bottom left
|
||||
( 1.0, 1.0), // bottom right
|
||||
(-1.0, -1.0), // top left
|
||||
( 1.0, 1.0), // bottom right
|
||||
( 1.0, -1.0), // top right
|
||||
],
|
||||
size: size,
|
||||
color: color,
|
||||
textured: false,
|
||||
@@ -58,6 +68,14 @@ impl Sprite {
|
||||
(position.0 + fsize.0, position.1 ), // top right
|
||||
],
|
||||
position: position,
|
||||
ti_position: [
|
||||
(-1.0, -1.0), // top left
|
||||
(-1.0, 1.0), // bottom left
|
||||
( 1.0, 1.0), // bottom right
|
||||
(-1.0, -1.0), // top left
|
||||
( 1.0, 1.0), // bottom right
|
||||
( 1.0, -1.0), // top right
|
||||
],
|
||||
size: size,
|
||||
color: (0.0, 0.0, 0.0, 0.0),
|
||||
textured: true,
|
||||
@@ -78,6 +96,10 @@ impl Drawable for Sprite {
|
||||
self.color.clone()
|
||||
}
|
||||
|
||||
fn get_ti_coords(&self) -> Vec<(f32, f32)> {
|
||||
self.ti_position.to_vec()
|
||||
}
|
||||
|
||||
fn get_texture_handle(&self) -> Option<Arc<CanvasTextureHandle>> {
|
||||
match self.textured {
|
||||
true => {
|
||||
|
||||
Reference in New Issue
Block a user