fix(render): fix arrow glitch with 0 ftx

The use of `acos(θ)` works better than `atan(θ)`. Just need to be
careful with the `sign` of `fty`.
This commit is contained in:
Jeremy Attali 2020-05-24 14:33:50 -04:00
parent 2adcf944f4
commit ec6e6abae7

View File

@ -1,5 +1,6 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <math.h>
#include <pango/pangocairo.h>
#include "swappy.h"
@ -105,11 +106,7 @@ static void render_shape_arrow(cairo_t *cr, struct swappy_paint_shape shape) {
return;
}
double theta = atan(fty / ftx);
if (ftx < DBL_EPSILON) {
theta = M_PI + theta;
}
double theta = copysign(1.0, fty) * acos(ftx / ftn);
// Draw line
cairo_save(cr);