Re: Shouldn't Cairo use/offer degrees rather than radians?
Andreas Lobinger <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAFfexC3bwS04pwm9FHyidS9kUEbSiEZfdyZf5Cek4BU42PoQVA@mail.gmail.com> |
Hello colleague(s), On Wed, Jul 5, 2017 at 10:37 PM, David Kastrup <[email protected]> wrote: > With this print format, the numbers would look the same. Do they > compare equal when comparing them with == ? And/or can you print with > something like 20 significant digits? > > The reason I ask: if the y coordinates of the curveto are _exactly_ > identical, this artifact would not actually be a consequence of > trigonometric functions unless cairo_copy_path is responsible for > minuscule changes as well. step1: i'm attaching the c-code i used to print the data step2: output (with %.20f) lobi@orange4:~/juliarepo$ gcc attachment1.c -I/usr/include/cairo/ -lcairo lobi@orange4:~/juliarepo$ ./a.out moveto 20.00000000000000000000,0.50390625000000000000 curveto 20.00000000000000000000,7.16796875000000000000 10.00000000000000000000,7.16796875000000000000 10.00000000000000000000,0.50390625000000000000 (and i'm pretty much convinced that path_copy just copies data without interfering) Without further debugging or looking into the code i'd assume we see here the process of cairo modeling the arc piecewise by curveto operators. And in this case a single curve - regarding the scaling and resolution of the output device seems to be enough. step3: please run and post. I'm really interested how your cairo is creating a different curve. -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo
attachment1.c
(text/x-csrc, 1.3 KB)
#include <cairo.h>
#include <math.h>
#include <stdio.h>
int main()
{
cairo_surface_t *surface =
cairo_image_surface_create (CAIRO_FORMAT_RGB16_565, 30, 20);
cairo_t *cr = cairo_create (surface);
cairo_set_line_width (cr, 2);
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_source_rgba (cr, 1, 1, 1, 1);
cairo_new_sub_path (cr);
cairo_arc (cr, 15, 0.501954078674316, 5, 0, M_PI);
int i;
cairo_path_t *path;
cairo_path_data_t *data;
path = cairo_copy_path (cr);
for (i=0; i < path->num_data; i += path->data[i].header.length) {
data = &path->data[i];
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
printf("moveto %.20f,%.20f\n",data[1].point.x, data[1].point.y);
break;
case CAIRO_PATH_LINE_TO:
printf("lineto %.20f,%.20f\n",data[1].point.x, data[1].point.y);
break;
case CAIRO_PATH_CURVE_TO:
printf("curveto %.20f,%.20f %.20f,%.20f %.20f,%.20f\n",
data[1].point.x, data[1].point.y,
data[2].point.x, data[2].point.y,
data[3].point.x, data[3].point.y);
break;
case CAIRO_PATH_CLOSE_PATH:
printf("closepath");
break;
}
}
cairo_stroke (cr);
cairo_destroy (cr);
cairo_surface_write_to_png (surface, "hello.png");
cairo_surface_destroy (surface);
return 0;
}