Skip to content

Commit 3f4467e

Browse files
committed
gradients
1 parent c6b7fca commit 3f4467e

File tree

1 file changed

+32
-8
lines changed
  • crates/bevy_debug_draw/src

1 file changed

+32
-8
lines changed

crates/bevy_debug_draw/src/lib.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,32 @@ impl Default for DebugDraw {
119119
impl DebugDraw {
120120
/// Draw a line from `start` to `end`.
121121
pub fn line(&mut self, start: Vec3, end: Vec3, color: Color) {
122+
self.line_gradient(start, end, color, color);
123+
}
124+
125+
/// Draw a line from `start` to `end`.
126+
pub fn line_gradient(&mut self, start: Vec3, end: Vec3, start_color: Color, end_color: Color) {
122127
self.positions.extend([start.to_array(), end.to_array()]);
123-
let color = color.as_linear_rgba_f32();
124-
self.colors.extend([color, color]);
128+
self.colors.extend([
129+
start_color.as_linear_rgba_f32(),
130+
end_color.as_linear_rgba_f32(),
131+
]);
125132
}
126133

127134
/// Draw a line from `start` to `start + vector`.
128135
pub fn ray(&mut self, start: Vec3, vector: Vec3, color: Color) {
129-
self.line(start, start + vector, color);
136+
self.ray_gradient(start, vector, color, color);
137+
}
138+
139+
/// Draw a line from `start` to `start + vector`.
140+
pub fn ray_gradient(
141+
&mut self,
142+
start: Vec3,
143+
vector: Vec3,
144+
start_color: Color,
145+
end_color: Color,
146+
) {
147+
self.line_gradient(start, start + vector, start_color, end_color);
130148
}
131149

132150
/// Draw a circle at `position` with the flat side facing `normal`.
@@ -189,14 +207,20 @@ impl DebugDraw {
189207
.extend(std::iter::repeat(color.as_linear_rgba_f32()).take(24))
190208
}
191209

192-
/// Draw an axis-aligned box.
193-
pub fn aab(&mut self, position: Vec3, size: Vec3, color: Color) {
194-
self.cuboid(position, Quat::IDENTITY, size, color);
210+
/// Draw a line from `start` to `end`.
211+
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: Color) {
212+
self.line_gradient_2d(start, end, color, color);
195213
}
196214

197215
/// Draw a line from `start` to `end`.
198-
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: Color) {
199-
self.line(start.extend(0.), end.extend(0.), color);
216+
pub fn line_gradient_2d(
217+
&mut self,
218+
start: Vec2,
219+
end: Vec2,
220+
start_color: Color,
221+
end_color: Color,
222+
) {
223+
self.line_gradient(start.extend(0.), end.extend(0.), start_color, end_color);
200224
}
201225

202226
/// Draw a line from `start` to `start + vector`.

0 commit comments

Comments
 (0)