(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64)
| 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); |
no test coverage detected