test arc failed
scriptiot-dev opened this issue · comments
static void test_arc(const char * filename)
{
plutovg_surface_t * surface = plutovg_surface_create(256, 256);
plutovg_t * ctx = plutovg_create(surface);
double xc = 128.0;
double yc = 128.0;
double radius = 100.0;
double angle1 = 45.0 * (M_PI / 180.0);
double angle2 = 180.0 * (M_PI / 180.0);
plutovg_set_line_width(ctx, 10.0);
plutovg_arc(ctx, xc, yc, radius, angle1, angle2, 0);
plutovg_stroke(ctx);
plutovg_set_source_rgba(ctx, 1, 0.2, 0.2, 0.6);
plutovg_set_line_width(ctx, 6.0);
plutovg_arc(ctx, xc, yc, 10.0, 0, 2 * M_PI, 0);
plutovg_fill(ctx);
plutovg_arc(ctx, xc, yc, radius, angle1, angle1, 0);
plutovg_line_to(ctx, xc, yc);
plutovg_arc(ctx, xc, yc, radius, angle2, angle2, 0);
plutovg_line_to(ctx, xc, yc);
plutovg_stroke(ctx);
plutovg_surface_write_to_png(surface, filename);
plutovg_destroy(ctx);
plutovg_surface_destroy(surface);
}
static void test_arc_negative(const char * filename)
{
plutovg_surface_t * surface = plutovg_surface_create(256, 256);
plutovg_t * ctx = plutovg_create(surface);
double xc = 128.0;
double yc = 128.0;
double radius = 100.0;
double angle1 = 45.0 * (M_PI / 180.0);
double angle2 = 180.0 * (M_PI / 180.0);
plutovg_set_line_width(ctx, 10.0);
plutovg_arc(ctx, xc, yc, radius, angle1, angle2, 1);
plutovg_stroke(ctx);
plutovg_set_source_rgba(ctx, 1, 0.2, 0.2, 0.6);
plutovg_set_line_width(ctx, 6.0);
plutovg_arc(ctx, xc, yc, 10.0, 0, 2 * M_PI, 0);
plutovg_fill(ctx);
plutovg_arc(ctx, xc, yc, radius, angle1, angle1, 0);
plutovg_line_to(ctx, xc, yc);
plutovg_arc(ctx, xc, yc, radius, angle2, angle2, 0);
plutovg_line_to(ctx, xc, yc);
plutovg_stroke(ctx);
plutovg_surface_write_to_png(surface, filename);
plutovg_destroy(ctx);
plutovg_surface_destroy(surface);
}
Thank you for opening this issue....
The current arc mathematics is bizarre... I will try to fix it over the weekend.
@scriptiot-dev Fixed : 23135be
nice job ! test OK @sammycage
static void test_rounded_rectangle(const char * filename)
{
plutovg_surface_t * surface = plutovg_surface_create(256, 256);
plutovg_t * ctx = plutovg_create(surface);
double x = 25.6,
y = 25.6,
width = 204.8,
height = 204.8,
aspect = 1.0,
corner_radius = height / 10.0;
double radius = corner_radius / aspect;
double degrees = M_PI / 180.0;
plutovg_new_path(ctx);
plutovg_arc(ctx, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees, 0);
plutovg_arc(ctx, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees, 0);
plutovg_arc(ctx, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees, 0);
plutovg_arc(ctx, x + radius, y + radius, radius, 180 * degrees, 270 * degrees, 0);
plutovg_close_path(ctx);
plutovg_set_source_rgb(ctx, 0.5, 0.5, 1);
plutovg_fill_preserve(ctx);
plutovg_set_source_rgba(ctx, 0.5, 0, 0, 0.5);
plutovg_set_line_width(ctx, 10.0);
plutovg_stroke(ctx);
plutovg_surface_write_to_png(surface, filename);
plutovg_destroy(ctx);
plutovg_surface_destroy(surface);
}
Yesterday's version was OK, today is wrong
Fixed : c76824d
Test is ok, very good! Thanks very much ! @sammycage