Skip to content

Commit

Permalink
SET(CMAKE_C_EXTENSIONS OFF), replace remainings M_PI by defined M_PIF
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbruyere committed Mar 25, 2022
1 parent 24dab0d commit 5454492
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
SET(LANG "CXX")
SET(CMAKE_C_STANDARD 11)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_C_EXTENSIONS OFF)

OPTION (VKVG_BUILD_SHARED_LIB "Build using shared libraries" ON)

Expand Down
8 changes: 4 additions & 4 deletions src/vkvg_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,13 @@ vkvg_status_t vkvg_rounded_rectangle (VkvgContext ctx, float x, float y, float w
radius = fmin (w / 2.0f, h / 2.0f);

vkvg_move_to(ctx, x, y + radius);
vkvg_arc(ctx, x + radius, y + radius, radius, (float)M_PI, (float)-M_PI_2);
vkvg_arc(ctx, x + radius, y + radius, radius, M_PIF, -M_PIF_2);
vkvg_line_to(ctx, x + w - radius, y);
vkvg_arc(ctx, x + w - radius, y + radius, radius, (float)-M_PI_2, 0);
vkvg_arc(ctx, x + w - radius, y + radius, radius, -M_PIF_2, 0);
vkvg_line_to(ctx, x + w, y + h - radius);
vkvg_arc(ctx, x + w - radius, y + h - radius, radius, 0, (float)M_PI_2);
vkvg_arc(ctx, x + w - radius, y + h - radius, radius, 0, M_PIF_2);
vkvg_line_to(ctx, x + radius, y + h);
vkvg_arc(ctx, x + radius, y + h - radius, radius, (float)M_PI_2, (float)M_PI);
vkvg_arc(ctx, x + radius, y + h - radius, radius, M_PIF_2, M_PIF);
vkvg_line_to(ctx, x, y + radius);
vkvg_close_path(ctx);

Expand Down
6 changes: 3 additions & 3 deletions src/vkvg_context_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ float _get_arc_step (VkvgContext ctx, float radius) {
vkvg_matrix_get_scale (&ctx->pushConsts.mat, &sx, &sy);
float r = radius * fabsf(fmaxf(sx,sy));
if (r < 30.0f)
return fminf(M_PI / 3.f, M_PI / r);
return fminf(M_PI / 3.f,M_PI / (r * 0.4f));
return fminf(M_PIF / 3.f, M_PIF / r);
return fminf(M_PIF / 3.f,M_PIF / (r * 0.4f));
}
void _create_gradient_buff (VkvgContext ctx){
vkvg_buffer_create (ctx->dev,
Expand Down Expand Up @@ -1542,7 +1542,7 @@ void _elliptic_arc (VkvgContext ctx, float x1, float y1, float x2, float y2, boo
double theta = sa;
double ea = sa + delta_theta;

float step = fmaxf(0.001f, fminf(M_PI, _get_arc_step(ctx, fminf (rx, ry))*0.1f));
float step = fmaxf(0.001f, fminf(M_PIF, _get_arc_step(ctx, fminf (rx, ry))*0.1f));

p = (vec2) {
rx * cosf (theta),
Expand Down

0 comments on commit 5454492

Please sign in to comment.