Skip to content
Snippets Groups Projects
Commit c91eb54d authored by StarToaster's avatar StarToaster
Browse files

Possibly fixed nine_patch.

parent ad0c5750
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,13 @@ pub fn extract_nine_patch( ...@@ -59,6 +59,13 @@ pub fn extract_nine_patch(
uv_min: None, uv_min: None,
}; };
let top_uv_min_y = (image_size.y - border.top) / image_size.y;
let top_uv_max_y = 1.0;
let bottom_uv_min_y = 0.0;
let bottom_uv_max_y = border.bottom / image_size.y;
let middle_uv_min_y = border.bottom / image_size.y;
let middle_uv_max_y = (image_size.y - border.top) / image_size.y;
// TOP // TOP
let top_left_quad = ExtractQuadBundle { let top_left_quad = ExtractQuadBundle {
extracted_quad: ExtractedQuad { extracted_quad: ExtractedQuad {
...@@ -66,8 +73,8 @@ pub fn extract_nine_patch( ...@@ -66,8 +73,8 @@ pub fn extract_nine_patch(
min: Vec2::new(layout.posx, layout.posy), min: Vec2::new(layout.posx, layout.posy),
max: Vec2::new(layout.posx + border.left, layout.posy + border.top), max: Vec2::new(layout.posx + border.left, layout.posy + border.top),
}, },
uv_min: Some(Vec2::new(0.0, border.top / image_size.y)), uv_min: Some(Vec2::new(0.0, top_uv_min_y)),
uv_max: Some(Vec2::new(border.left / image_size.x, 0.0)), uv_max: Some(Vec2::new(border.left / image_size.x, top_uv_max_y)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -82,9 +89,9 @@ pub fn extract_nine_patch( ...@@ -82,9 +89,9 @@ pub fn extract_nine_patch(
}, },
uv_min: Some(Vec2::new( uv_min: Some(Vec2::new(
(image_size.x - border.left) / image_size.x, (image_size.x - border.left) / image_size.x,
border.top / image_size.y, top_uv_min_y,
)), )),
uv_max: Some(Vec2::new(1.0, 0.0)), uv_max: Some(Vec2::new(1.0, top_uv_max_y)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -101,11 +108,11 @@ pub fn extract_nine_patch( ...@@ -101,11 +108,11 @@ pub fn extract_nine_patch(
layout.posy + border.top, layout.posy + border.top,
), ),
}, },
uv_min: Some(Vec2::new( uv_min: Some(Vec2::new(border.left / image_size.x, top_uv_min_y)),
border.left / image_size.x, uv_max: Some(Vec2::new(
border.top / image_size.y, (image_size.x - border.left) / image_size.x,
top_uv_max_y,
)), )),
uv_max: Some(Vec2::new((image_size.x - border.left) / image_size.x, 0.0)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -119,11 +126,8 @@ pub fn extract_nine_patch( ...@@ -119,11 +126,8 @@ pub fn extract_nine_patch(
min: Vec2::new(layout.posx, bottom_y_pos), min: Vec2::new(layout.posx, bottom_y_pos),
max: Vec2::new(layout.posx + border.left, bottom_y_pos + border.bottom), max: Vec2::new(layout.posx + border.left, bottom_y_pos + border.bottom),
}, },
uv_min: Some(Vec2::new(0.0, 1.0)), uv_min: Some(Vec2::new(0.0, bottom_uv_min_y)),
uv_max: Some(Vec2::new( uv_max: Some(Vec2::new(border.left / image_size.x, bottom_uv_max_y)),
border.left / image_size.x,
(image_size.y - border.bottom) / image_size.y,
)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -136,11 +140,11 @@ pub fn extract_nine_patch( ...@@ -136,11 +140,11 @@ pub fn extract_nine_patch(
min: Vec2::new(bottom_right_pos_x, bottom_y_pos), min: Vec2::new(bottom_right_pos_x, bottom_y_pos),
max: Vec2::new(bottom_right_pos_x + border.left, bottom_y_pos + border.top), max: Vec2::new(bottom_right_pos_x + border.left, bottom_y_pos + border.top),
}, },
uv_min: Some(Vec2::new((image_size.x - border.left) / image_size.x, 1.0)), uv_min: Some(Vec2::new(
uv_max: Some(Vec2::new( (image_size.x - border.left) / image_size.x,
1.0, bottom_uv_min_y,
(image_size.y - border.bottom) / image_size.y,
)), )),
uv_max: Some(Vec2::new(1.0, bottom_uv_max_y)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -157,10 +161,10 @@ pub fn extract_nine_patch( ...@@ -157,10 +161,10 @@ pub fn extract_nine_patch(
bottom_y_pos + border.top, bottom_y_pos + border.top,
), ),
}, },
uv_min: Some(Vec2::new(border.left / image_size.x, 1.0)), uv_min: Some(Vec2::new(border.left / image_size.x, bottom_uv_min_y)),
uv_max: Some(Vec2::new( uv_max: Some(Vec2::new(
(image_size.x - border.left) / image_size.x, (image_size.x - border.left) / image_size.x,
(image_size.y - border.bottom) / image_size.y, bottom_uv_max_y,
)), )),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
...@@ -179,14 +183,8 @@ pub fn extract_nine_patch( ...@@ -179,14 +183,8 @@ pub fn extract_nine_patch(
left_middle_pos_y + left_middle_size_y, left_middle_pos_y + left_middle_size_y,
), ),
}, },
uv_min: Some(Vec2::new( uv_min: Some(Vec2::new(0.0, middle_uv_min_y)),
0.0, uv_max: Some(Vec2::new(border.left / image_size.x, middle_uv_max_y)),
(image_size.y - border.bottom) / image_size.y,
)),
uv_max: Some(Vec2::new(
border.left / image_size.x,
border.top / image_size.y,
)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -206,9 +204,9 @@ pub fn extract_nine_patch( ...@@ -206,9 +204,9 @@ pub fn extract_nine_patch(
}, },
uv_min: Some(Vec2::new( uv_min: Some(Vec2::new(
(image_size.x - border.left) / image_size.x, (image_size.x - border.left) / image_size.x,
(image_size.y - border.bottom) / image_size.y, middle_uv_min_y,
)), )),
uv_max: Some(Vec2::new(1.0, border.top / image_size.y)), uv_max: Some(Vec2::new(1.0, middle_uv_max_y)),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
}; };
...@@ -225,13 +223,10 @@ pub fn extract_nine_patch( ...@@ -225,13 +223,10 @@ pub fn extract_nine_patch(
min: Vec2::new(middle_pos_x, middle_pos_y), min: Vec2::new(middle_pos_x, middle_pos_y),
max: Vec2::new(middle_pos_x + middle_size_x, middle_pos_y + middle_size_y), max: Vec2::new(middle_pos_x + middle_size_x, middle_pos_y + middle_size_y),
}, },
uv_min: Some(Vec2::new( uv_min: Some(Vec2::new(border.left / image_size.x, middle_uv_min_y)),
border.left / image_size.x,
border.top / image_size.y,
)),
uv_max: Some(Vec2::new( uv_max: Some(Vec2::new(
(image_size.x - border.right) / image_size.x, (image_size.x - border.right) / image_size.x,
(image_size.y - border.bottom) / image_size.y, middle_uv_max_y,
)), )),
..extracted_quad_template.clone() ..extracted_quad_template.clone()
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment