Skip to content

Commit 1045765

Browse files
committed
Implemented arc/pieslices.
+ Tests are running
1 parent 1dde67f commit 1045765

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

crates/icy_engine/src/parsers/igs/paint.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,14 @@ impl DrawExecutor {
431431
}
432432

433433
fn draw_elliptical_pieslice(&mut self, xm: i32, ym: i32, xr: i32, yr: i32, beg_ang: i32, end_ang: i32) {
434-
let points = gdp_curve(xm, ym, xr, yr, beg_ang, end_ang);
434+
let mut points = gdp_curve(xm, ym, xr, yr, beg_ang * 10, end_ang * 10);
435+
points.extend_from_slice(&[xm, ym]);
435436
self.draw_poly(&points, self.line_color, true);
436437
}
437438

438439
fn fill_elliptical_pieslice(&mut self, xm: i32, ym: i32, xr: i32, yr: i32, beg_ang: i32, end_ang: i32) {
439-
let points = gdp_curve(xm, ym, xr, yr, beg_ang, end_ang);
440+
let mut points = gdp_curve(xm, ym, xr, yr, beg_ang * 10, end_ang * 10);
441+
points.extend_from_slice(&[xm, ym]);
440442
self.fill_poly(&points);
441443
}
442444

@@ -461,7 +463,7 @@ impl DrawExecutor {
461463
}
462464

463465
fn draw_arc(&mut self, xm: i32, ym: i32, a: i32, b: i32, beg_ang: i32, end_ang: i32) {
464-
let points = gdp_curve(xm, ym, a, b, beg_ang, end_ang);
466+
let points = gdp_curve(xm, ym, a, b, beg_ang * 10, end_ang * 10);
465467
self.draw_poly(&points, self.line_color, false);
466468
}
467469

@@ -500,6 +502,10 @@ impl DrawExecutor {
500502
}
501503

502504
fn fill_poly(&mut self, points: &[i32]) {
505+
if self.hollow_set {
506+
self.draw_poly(points, self.fill_color, true);
507+
return;
508+
}
503509
let max_vertices = 512;
504510
let mut y_max = points[1];
505511
let mut y_min = points[1];
@@ -1143,7 +1149,7 @@ impl CommandExecutor for DrawExecutor {
11431149
return Err(anyhow::anyhow!("AttributeForFills command requires 3 arguments"));
11441150
}
11451151
let xrad = parameters[2];
1146-
let yrad = self.calc_circle_y_rad(xrad);
1152+
let yrad = self.calc_circle_y_rad(xrad).max(1);
11471153
self.fill_ellipse(parameters[0], parameters[1], xrad, yrad);
11481154
if self.draw_border {
11491155
self.draw_circle(parameters[0], parameters[1], xrad);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)