MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / draw_line

Method draw_line

native/shared/src/renderer/mod.rs:11869–11888  ·  view source on GitHub ↗
(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64)

Source from the content-addressed store, hash-verified

11867 }
11868
11869 pub fn draw_line(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64) {
11870 self.ensure_draw_state(0);
11871 let color = Self::color_to_f32(r, g, b, a);
11872 let dx = (x2 - x1) as f32;
11873 let dy = (y2 - y1) as f32;
11874 let len = (dx * dx + dy * dy).sqrt();
11875 if len == 0.0 { return; }
11876 let half_t = (thickness as f32) * 0.5;
11877 let nx = -dy / len * half_t;
11878 let ny = dx / len * half_t;
11879 let (x1, y1, x2, y2) = (x1 as f32, y1 as f32, x2 as f32, y2 as f32);
11880 let base = self.vertices_2d.len() as u32;
11881
11882 self.vertices_2d.push(Vertex2D { position: [x1 + nx, y1 + ny], uv: [0.0, 0.0], color });
11883 self.vertices_2d.push(Vertex2D { position: [x1 - nx, y1 - ny], uv: [0.0, 0.0], color });
11884 self.vertices_2d.push(Vertex2D { position: [x2 - nx, y2 - ny], uv: [0.0, 0.0], color });
11885 self.vertices_2d.push(Vertex2D { position: [x2 + nx, y2 + ny], uv: [0.0, 0.0], color });
11886
11887 self.indices_2d.extend_from_slice(&[base, base + 1, base + 2, base, base + 2, base + 3]);
11888 }
11889
11890 pub fn draw_circle(&mut self, cx: f64, cy: f64, radius: f64, r: f64, g: f64, b: f64, a: f64) {
11891 self.ensure_draw_state(0);

Callers 8

bloom_draw_lineFunction · 0.80
bloom_draw_lineFunction · 0.80
bloom_draw_lineFunction · 0.80
bloom_draw_lineFunction · 0.80
draw_circle_linesMethod · 0.80
bloom_draw_lineFunction · 0.80
bloom_draw_lineFunction · 0.80
bloom_draw_lineFunction · 0.80

Calls 2

ensure_draw_stateMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected