diff --git a/magic/icons/epitrochoid_edge.png b/magic/icons/epitrochoid_edge.png index f7671f042..60dfd1798 100644 Binary files a/magic/icons/epitrochoid_edge.png and b/magic/icons/epitrochoid_edge.png differ diff --git a/magic/icons/epitrochoid_inside.png b/magic/icons/epitrochoid_inside.png index 8e8757e60..ad8104fb8 100644 Binary files a/magic/icons/epitrochoid_inside.png and b/magic/icons/epitrochoid_inside.png differ diff --git a/magic/icons/epitrochoid_outside.png b/magic/icons/epitrochoid_outside.png index 71e0b9a25..6cd1824be 100644 Binary files a/magic/icons/epitrochoid_outside.png and b/magic/icons/epitrochoid_outside.png differ diff --git a/magic/icons/hypotrochoid_edge.png b/magic/icons/hypotrochoid_edge.png index 6915917fd..7f0653529 100644 Binary files a/magic/icons/hypotrochoid_edge.png and b/magic/icons/hypotrochoid_edge.png differ diff --git a/magic/icons/hypotrochoid_inside.png b/magic/icons/hypotrochoid_inside.png index 84af2dfc1..a69284a13 100644 Binary files a/magic/icons/hypotrochoid_inside.png and b/magic/icons/hypotrochoid_inside.png differ diff --git a/magic/icons/hypotrochoid_outside.png b/magic/icons/hypotrochoid_outside.png index f84348ff0..b0c3a0b03 100644 Binary files a/magic/icons/hypotrochoid_outside.png and b/magic/icons/hypotrochoid_outside.png differ diff --git a/magic/src/trochoids.c b/magic/src/trochoids.c index a4e2fde45..609a979fe 100644 --- a/magic/src/trochoids.c +++ b/magic/src/trochoids.c @@ -7,7 +7,7 @@ by Bill Kendrick with help from Pere Pujal Carabantes - January 6, 2024 - January 16, 2024 + January 6, 2024 - January 17, 2024 */ #include @@ -360,6 +360,10 @@ void trochoids_work(magic_api * api, int which, which == TOOL_HYPOTROCHOID_NOSIZES_2 || which == TOOL_HYPOTROCHOID_NOSIZES_3) { /* Hypotrochoid */ + if (R == r) { + r += 10; + } + r_ratio = (float) (R - r) / (float) r; } else { /* Epitrochoid */ @@ -417,16 +421,18 @@ void trochoids_work(magic_api * api, int which, showing the mechanism that would be used to generate the pattern */ rotator_anim_a = (int) (atan2(y - trochoids_y, x - trochoids_x) / M_PI * 180.0); - for (a = 0; a < 360; a = a + 2) { - /* Stator (fixed circle) */ + /* Stator (fixed circle) */ + for (a = 0; a < 360; a = a + 360 / R) { px = (int) ((float) trochoids_x + ((float) R * deg_cos(a))); py = (int) ((float) trochoids_y - ((float) R * deg_sin(a))); - api->xorpixel(canvas, px, py); - api->xorpixel(canvas, px + 1, py); - api->xorpixel(canvas, px, py + 1); - api->xorpixel(canvas, px + 1, py + 1); + api->putpixel(canvas, px, py, 0); + api->putpixel(canvas, px + 1, py, 0xff); + api->putpixel(canvas, px, py + 1, 0); + api->putpixel(canvas, px + 1, py + 1, 0xff); + } - /* Rotator (rolling circle) */ + /* Rotator (rolling circle) */ + for (a = 0; a < 360; a = a + 360 / r) { if (which == TOOL_HYPOTROCHOID_SIZES || which == TOOL_HYPOTROCHOID_NOSIZES_1 || which == TOOL_HYPOTROCHOID_NOSIZES_2 || @@ -452,13 +458,22 @@ void trochoids_work(magic_api * api, int which, which == TOOL_HYPOTROCHOID_NOSIZES_2 || which == TOOL_HYPOTROCHOID_NOSIZES_3) { /* Hypotrochoid */ - px = trochoids_x + (((R - r) * deg_cos(rotator_anim_a)) + (d * deg_cos(rotator_anim_a))); - py = trochoids_y + (((R - r) * deg_sin(rotator_anim_a)) - (d * deg_sin(rotator_anim_a))); + px = trochoids_x + (((R - r) * deg_cos(rotator_anim_a)) + (d * deg_cos(360 - rotator_anim_a))); + py = trochoids_y + (((R - r) * deg_sin(rotator_anim_a)) - (d * deg_sin(360 - rotator_anim_a))); + + px2 = trochoids_x + (((R - r) * deg_cos(rotator_anim_a))); + py2 = trochoids_y + (((R - r) * deg_sin(rotator_anim_a))); } else { /* Epitrochoid */ - px = trochoids_x + (((R + r) * deg_cos(rotator_anim_a)) - (d * deg_cos(rotator_anim_a))); - py = trochoids_y + (((R + r) * deg_sin(rotator_anim_a)) - (d * deg_sin(rotator_anim_a))); + px = trochoids_x + (((R + r) * deg_cos(rotator_anim_a)) - (d * deg_cos(360 - rotator_anim_a))); + py = trochoids_y + (((R + r) * deg_sin(rotator_anim_a)) - (d * deg_sin(360 - rotator_anim_a))); + + px2 = trochoids_x + (((R + r) * deg_cos(rotator_anim_a))); + py2 = trochoids_y + (((R + r) * deg_sin(rotator_anim_a))); } + + api->line((void *)api, which, canvas, snapshot, px, py, px2, py2, 2, trochoids_line_callback); + for (int yy = -2; yy <= 2; yy++) { for (int xx = -2; xx <= 2; xx++) { api->putpixel(canvas, px + xx, py + yy, trochoids_color);