mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
More natural limits for step size when sampling paramterized curve
This commit is contained in:
@@ -700,8 +700,9 @@ draw_parametrized_curve_with_derivative(
|
|||||||
Canvas *self, void *curve_data, double line_width, curve_func xfunc, curve_func yfunc, curve_func x_prime, curve_func y_prime,
|
Canvas *self, void *curve_data, double line_width, curve_func xfunc, curve_func yfunc, curve_func x_prime, curve_func y_prime,
|
||||||
int x_offset, int yoffset, double thickness_fudge
|
int x_offset, int yoffset, double thickness_fudge
|
||||||
) {
|
) {
|
||||||
double step = 1.0 / self->height;
|
double larger_dim = fmax(self->height, self->width);
|
||||||
const double min_step = 1.0 / (100 * self->height);
|
double step = 1.0 / larger_dim;
|
||||||
|
const double min_step = 1.0 / (100 * larger_dim), max_step = step;
|
||||||
line_width = fmax(1., line_width);
|
line_width = fmax(1., line_width);
|
||||||
const double half_thickness = line_width / 2.0;
|
const double half_thickness = line_width / 2.0;
|
||||||
const double distance_limit = half_thickness + thickness_fudge;
|
const double distance_limit = half_thickness + thickness_fudge;
|
||||||
@@ -725,7 +726,7 @@ draw_parametrized_curve_with_derivative(
|
|||||||
double dx = x_prime(curve_data, t), dy = y_prime(curve_data, t);
|
double dx = x_prime(curve_data, t), dy = y_prime(curve_data, t);
|
||||||
double d = sqrt(dx * dx + dy * dy);
|
double d = sqrt(dx * dx + dy * dy);
|
||||||
step = 1.0 / fmax(1e-6, d);
|
step = 1.0 / fmax(1e-6, d);
|
||||||
step = fmax(min_step, fmin(step, 0.01));
|
step = fmax(min_step, fmin(step, max_step));
|
||||||
t = fmin(t + step, 1.0);
|
t = fmin(t + step, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user