mirror of
https://github.com/jtheoof/swappy.git
synced 2024-09-11 14:55:49 +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 <gdk/gdk.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <math.h>
|
||||||
#include <pango/pangocairo.h>
|
#include <pango/pangocairo.h>
|
||||||
|
|
||||||
#include "swappy.h"
|
#include "swappy.h"
|
||||||
@ -105,11 +106,7 @@ static void render_shape_arrow(cairo_t *cr, struct swappy_paint_shape shape) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double theta = atan(fty / ftx);
|
double theta = copysign(1.0, fty) * acos(ftx / ftn);
|
||||||
|
|
||||||
if (ftx < DBL_EPSILON) {
|
|
||||||
theta = M_PI + theta;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw line
|
// Draw line
|
||||||
cairo_save(cr);
|
cairo_save(cr);
|
||||||
|
Loading…
Reference in New Issue
Block a user