]> granicus.if.org Git - graphviz/commit
use input gradient angle rather than computed gradient angle when checking for 0
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 13 Nov 2022 22:22:03 +0000 (14:22 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 17 Nov 2022 03:06:29 +0000 (19:06 -0800)
commitbf73c13de463ffeaa66dc8e8607d04ac96dad72e
tree717f4434ffdec4e761c42a70f8a16baccd97a271
parentbd182b29ddfebefe5fcfb8335283deb0bfe73813
use input gradient angle rather than computed gradient angle when checking for 0

When using radial gradients, a value of 0 is interpreted differently to other
values:¹

  a value of zero causes the colors to transform radially from the center; for
  non-zero values, the colors transform from a point near the object’s periphery
  as specified by the value.

The code affected in this commit is looking for this situation, but was
unnecessarily using the computed gradient angle. If the original is zero, the
computed angle will also be zero. So we can simplify this code for both human
readers and the compiler by using the original (integer) angle.

This squashes the warnings:

  gvrender_core_dot.c: In function ‘xdot_gradient_fillcolor’:
  gvrender_core_dot.c:644:19: warning: comparing floating-point with ‘==’ or
    ‘!=’ is unsafe [-Wfloat-equal]
    644 |         if (angle == 0) {
        |                   ^~
  gvrender_core_svg.c: In function ‘svg_rgradstyle’:
  gvrender_core_svg.c:602:15: warning: comparing floating-point with ‘==’ or
    ‘!=’ is unsafe [-Wfloat-equal]
    602 |     if (angle == 0.) {
        |               ^~
  gvrender_pango.c:322:19: warning: comparing floating-point with ‘==’ or ‘!=’
    is unsafe [-Wfloat-equal]
    322 |         if (angle == 0) {
        |                   ^~

Gitlab: related to #2313

¹ https://graphviz.org/docs/attrs/gradientangle/
plugin/core/gvrender_core_dot.c
plugin/core/gvrender_core_svg.c
plugin/pango/gvrender_pango.c