(&mut self, cx: f64, cy: f64, sides: f64, radius: f64, rotation: f64, r: f64, g: f64, b: f64, a: f64)
| 11935 | } |
| 11936 | |
| 11937 | pub fn draw_poly(&mut self, cx: f64, cy: f64, sides: f64, radius: f64, rotation: f64, r: f64, g: f64, b: f64, a: f64) { |
| 11938 | self.ensure_draw_state(0); |
| 11939 | let color = Self::color_to_f32(r, g, b, a); |
| 11940 | let n = sides as u32; |
| 11941 | if n < 3 { return; } |
| 11942 | let base = self.vertices_2d.len() as u32; |
| 11943 | let (cx, cy, radius) = (cx as f32, cy as f32, radius as f32); |
| 11944 | let rot_rad = (rotation as f32).to_radians(); |
| 11945 | |
| 11946 | self.vertices_2d.push(Vertex2D { position: [cx, cy], uv: [0.0, 0.0], color }); |
| 11947 | for i in 0..n { |
| 11948 | let angle = rot_rad + (i as f32) / (n as f32) * std::f32::consts::TAU; |
| 11949 | self.vertices_2d.push(Vertex2D { |
| 11950 | position: [cx + radius * angle.cos(), cy + radius * angle.sin()], |
| 11951 | uv: [0.0, 0.0], |
| 11952 | color, |
| 11953 | }); |
| 11954 | } |
| 11955 | for i in 0..n { |
| 11956 | let next = if i + 1 < n { i + 1 } else { 0 }; |
| 11957 | self.indices_2d.extend_from_slice(&[base, base + 1 + i, base + 1 + next]); |
| 11958 | } |
| 11959 | } |
| 11960 | |
| 11961 | // ============================================================ |
| 11962 | // Textured 2D drawing (for text atlas, sprites, etc.) |
no test coverage detected