Re: Shouldn't Cairo use/offer degrees rather than radians?

[email protected]
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
 
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;
}

-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.