mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-25 16:38:42 -06:00
fix rounded rect gradient
This commit is contained in:
parent
6549a6a410
commit
d1588932e5
|
@ -159,29 +159,43 @@ impl UiDrawCall {
|
||||||
let x = angle.sin();
|
let x = angle.sin();
|
||||||
let y = angle.cos();
|
let y = angle.cos();
|
||||||
//Top-right corner
|
//Top-right corner
|
||||||
draw_call.vertices.push(UiVertex {
|
let mut corner_impl = |rp: Vec2, color: &Corners<Vec4>, uv: Vec2| {
|
||||||
position: *position + vec2(x, 1. - y) * corner.radius.top_right + vec2(size.x - corner.radius.top_right, 0.),
|
//TODO: also calculate proper uv
|
||||||
color: color.top_right,
|
let rrp = rp / *size;
|
||||||
uv: uvs.top_right,
|
let color_at_point =
|
||||||
});
|
color.bottom_right * rrp.x * rrp.y +
|
||||||
|
color.top_right * rrp.x * (1. - rrp.y) +
|
||||||
|
color.bottom_left * (1. - rrp.x) * rrp.y +
|
||||||
|
color.top_left * (1. - rrp.x) * (1. - rrp.y);
|
||||||
|
draw_call.vertices.push(UiVertex {
|
||||||
|
position: *position + rp,
|
||||||
|
color: color_at_point,
|
||||||
|
uv,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
corner_impl(
|
||||||
|
vec2(x, 1. - y) * corner.radius.top_right + vec2(size.x - corner.radius.top_right, 0.),
|
||||||
|
color,
|
||||||
|
uvs.top_right,
|
||||||
|
);
|
||||||
//Bottom-right corner
|
//Bottom-right corner
|
||||||
draw_call.vertices.push(UiVertex {
|
corner_impl(
|
||||||
position: *position + vec2(x - 1., y) * corner.radius.bottom_right + vec2(size.x, size.y - corner.radius.bottom_right),
|
vec2(x - 1., y) * corner.radius.bottom_right + vec2(size.x, size.y - corner.radius.bottom_right),
|
||||||
color: color.bottom_right,
|
color,
|
||||||
uv: uvs.bottom_right,
|
uvs.bottom_right,
|
||||||
});
|
);
|
||||||
//Bottom-left corner
|
//Bottom-left corner
|
||||||
draw_call.vertices.push(UiVertex {
|
corner_impl(
|
||||||
position: *position + vec2(1. - x, y) * corner.radius.bottom_left + vec2(0., size.y - corner.radius.bottom_left),
|
vec2(1. - x, y) * corner.radius.bottom_left + vec2(0., size.y - corner.radius.bottom_left),
|
||||||
color: color.bottom_left,
|
color,
|
||||||
uv: uvs.bottom_left,
|
uvs.bottom_left,
|
||||||
});
|
);
|
||||||
//Top-left corner
|
//Top-left corner
|
||||||
draw_call.vertices.push(UiVertex {
|
corner_impl(
|
||||||
position: *position + vec2(1. - x, 1. - y) * corner.radius.top_left,
|
vec2(1. - x, 1. - y) * corner.radius.top_left,
|
||||||
color: color.top_left,
|
color,
|
||||||
uv: uvs.top_left,
|
uvs.top_left,
|
||||||
});
|
);
|
||||||
// mental illness:
|
// mental illness:
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
draw_call.indices.extend([
|
draw_call.indices.extend([
|
||||||
|
|
Loading…
Reference in a new issue