]> granicus.if.org Git - graphviz/commitdiff
get_gradient_points: take 'angle' as a double instead of a float
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 13 Nov 2021 01:29:12 +0000 (17:29 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 15 Nov 2021 15:54:17 +0000 (07:54 -0800)
The originating values used to compute an angle were generally doubles and
computation was done in `get_gradient_points` as if this value was a double
(e.g. calling `sin` and `cos`). Treating it consistently as a double squashes a
number of -Wfloat-conversion compiler warnings and improves precision.

lib/common/utils.c
lib/common/utils.h
plugin/core/gvrender_core_dot.c
plugin/core/gvrender_core_svg.c
plugin/pango/gvrender_pango.c

index 0ab5ff7f44b36f385b6e874588578806c21edc9c..bc6f6144e8a528cad0bc6350dd629ba67fa3bf1e 100644 (file)
@@ -1743,8 +1743,7 @@ void setEdgeType (graph_t* g, int dflt)
  * By default, this assumes a left-hand coordinate system (for svg); if RHS = 2 flag
  * is set, use standard coordinate system.
  */
-void get_gradient_points(pointf * A, pointf * G, int n, float angle, int flags)
-{
+void get_gradient_points(pointf *A, pointf *G, int n, double angle, int flags) {
     int i;
     double rx, ry;
     pointf min,max,center;
index 80d231749444ea61e3af053d29493441c9e68d2d..11021b9edc3a866ac2fd2c8c6313963f7e5dd74a 100644 (file)
@@ -106,7 +106,8 @@ extern "C" {
     UTILS_API bool overlap_label(textlabel_t *lp, boxf b);
     UTILS_API bool overlap_edge(edge_t *e, boxf b);
 
-    UTILS_API void get_gradient_points(pointf * A, pointf * G, int n, float angle, int flags);
+    UTILS_API void get_gradient_points(pointf *A, pointf *G, int n,
+                                       double angle, int flags);
 
     UTILS_API void processClusterEdges(graph_t * g);
 
index 9c827a1f0dce84b4f0960aca51b2678b8f129d42..8eb43e2d8afd649c7e2e52ec0163c5f372702300 100644 (file)
@@ -614,7 +614,7 @@ static void xdot_gradient_fillcolor (GVJ_t* job, int filled, pointf* A, int n)
     unsigned char buf0[BUFSIZ];
     agxbuf xb;
     obj_state_t* obj = job->obj;
-    float angle = obj->gradient_angle * M_PI / 180;
+    double angle = obj->gradient_angle * M_PI / 180;
     float r1,r2;
     pointf G[2],c1,c2;
 
index 24f3a3959775cc7af6c8e224b4ac0ec422438f5d..0fef81c45ca8e1c50d621bd358a690a22992e309 100644 (file)
@@ -493,12 +493,11 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span)
 static int svg_gradstyle(GVJ_t * job, pointf * A, int n)
 {
     pointf G[2];
-    float angle;
     static int gradId;
     int id = gradId++;
 
     obj_state_t *obj = job->obj;
-    angle = obj->gradient_angle * M_PI / 180;  //angle of gradient line
+    double angle = obj->gradient_angle * M_PI / 180; //angle of gradient line
     G[0].x = G[0].y = G[1].x = G[1].y = 0.;
     get_gradient_points(A, G, n, angle, 0);    //get points on gradient line
 
index f3a76a0b9567c6b71c84f3ee11f042a07726787e..5b626390d8236e07685edd79d800e29dadd4bd25 100644 (file)
@@ -306,7 +306,7 @@ static void cairogen_set_penstyle(GVJ_t *job, cairo_t *cr)
 static void cairo_gradient_fill (cairo_t* cr, obj_state_t* obj, int filled, pointf* A, int n)
 {
     cairo_pattern_t* pat;
-    float angle = obj->gradient_angle * M_PI / 180;
+    double angle = obj->gradient_angle * M_PI / 180;
     float r1,r2;
     pointf G[2],c1;