<font color='black' size='2' face='arial'><font size="2"><br>
Has anyone figured out a good explanation for this? I haven't been able to figure it out. It looks like the problem is tied to only one particular precision point. I don't know why that is. If I change the size of the surface, radius, y-point or even pi I get the same problem point. If I run with valgrind I get a different repetitive problem point. Maybe on some hardware this doesn't happen? I am testing on a Intel 32 bit Atom CPU N270 1.60GHz × 2 with Ubuntu16.04. This is my latest to try to figure out what is happening. <br>
<br>
Eric<br>
<br>
<br>
#include <cairo.h><br>
#include <stdio.h><br>
#include <math.h><br>
<br>
int main()<br>
{<br>
printf("%s\n", cairo_version_string());<br>
cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 30, 20);<br>
cairo_t *cr = cairo_create (surface);<br>
cairo_set_line_width (cr, 2);<br>
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);<br>
<br>
double test_number=0.0;<br>
double increment=0.1;<br>
int channels=4;<br>
int width=cairo_image_surface_get_width(surface);<br>
int height=cairo_image_surface_get_height(surface);<br>
int stride=cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);<br>
printf("width %i, height %i, stride %i\n", width, height, stride);<br>
unsigned char *s=cairo_image_surface_get_data(surface);<br>
unsigned char *pixels=s;<br>
//Safety for do loop.<br>
int safety=0;<br>
int counter=0;<br>
int i=0;<br>
int j=0;<br>
<br>
//Change the arc radius for each loop. Use i to change the test number for new search also.<br>
for(i=0;i<5;i++)<br>
{<br>
do<br>
{<br>
test_number+=increment; <br>
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);<br>
cairo_paint(cr);<br>
cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);<br>
//Test changing arc radius to see if this changes the numbers.<br>
cairo_arc(cr, 15, test_number, 5+i, 0, M_PI);<br>
cairo_stroke(cr); <br>
cairo_surface_flush(surface); <br>
<br>
//Look for the color pixels in the row.<br>
counter=0;<br>
for(j=0;j<width;j++)<br>
{<br>
if(pixels[i*stride+j*channels+1]!=0) counter++;<br>
} <br>
//Refine precision if the row was all 0's. Backup and start looking again.<br>
if(counter==0)<br>
{<br>
//Go back one.<br>
test_number-=increment;<br>
increment=increment*0.1;<br>
printf("%i %i %i %.15f, %.15f\n", i, counter, safety, test_number, increment);<br>
}<br>
<br>
if(safety>100)<br>
{<br>
printf("Couldn't find partial arc.\n");<br>
break;<br>
}<br>
safety++; <br>
}while(counter<1||counter>3);<br>
<br>
printf("Row %i %.15f ", i, test_number);<br>
for(j=0;j<width;j++)<br>
{<br>
printf("%i, ", pixels[i*stride+j*channels+1]);<br>
}<br>
printf("\n");<br>
<br>
safety=0;<br>
test_number=(double)i+1;<br>
increment=0.1;<br>
}<br>
<br>
cairo_destroy(cr);<br>
cairo_surface_destroy(surface);<br>
cairo_debug_reset_static_data();<br>
return 0;<br>
}<br>
</font></font>