[cairo] Shouldn't Cairo use/offer degrees rather than radians?

cecashon at aol.com cecashon at aol.com
Fri Jul 7 04:20:43 UTC 2017


 
If I take a look at the pixels, I can see the arc not making a half circle in this case. When I run the following program I get this output. This is with cairo 1.14.6. If I try the same program with Valgrind the half circle lines up?

Eric

...
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0 255 255 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
255 255 255 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
255 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 

...

With Valgrind
...
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0 255 255 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0 255 255 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0 255 255   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
...

#include <cairo.h>
#include <stdio.h>
#include <math.h>

int main()
{
  //cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_RGB16_565, 30, 20);
  cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 30, 20);
  cairo_t *cr = cairo_create (surface);
  cairo_set_line_width (cr, 2);
  cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
  cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
  cairo_paint(cr);

  cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
  cairo_arc (cr, 15, 0.501954078674316, 5, 0, M_PI);
  cairo_stroke (cr);
  cairo_destroy (cr);

  int i=0;
  int j=0;
  cairo_surface_flush(surface);
  int width = cairo_image_surface_get_width(surface);
  int height = cairo_image_surface_get_height(surface);
  int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, 30);
  int channels = 4;
  unsigned char *s=cairo_image_surface_get_data(surface);
  unsigned char *pixels=s;
  for(i=0;i<width;i++)
    {
      for(j=0;j<height;j++)
        {
          printf("%3i ", pixels[j*stride+i*channels+1]);
        }
      printf("\n");
    }

  cairo_surface_destroy (surface);
  return 0;
}

 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170707/c564cce6/attachment-0001.html>


More information about the cairo mailing list