mirror of
https://github.com/jtheoof/swappy.git
synced 2024-08-16 18:20:45 +03:00
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:
parent
2adcf944f4
commit
ec6e6abae7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user