[fpc-pascal] Trouble converting to pascal sample examples of cairo

Luiz Americo Pereira Camara luizmed at oi.com.br
Fri Oct 19 22:13:23 CEST 2007


I'm converting the cairo samples (http://cairographics.org/samples/ 
http://cvs.cairographics.org/cairo-demo/cairo_snippets/) to pascal.

I'm getting a runtime error 207 (invalid float operation in win32) in 
two specific examples (arc and arc_negative). All other examples works fine.

Here's the converted code snippet (a compilable example is attached):

  xc := 0.5;
  yc := 0.5;
  radius := 0.4;
  angle1 := 45.0  * (PI/180.0);  (* angles are specified *)
  angle2 := 180.0 * (PI/180.0);  (* in radians           *)

  cairo_arc (cr, xc, yc, radius, angle1, angle2); -> works fine
  cairo_stroke (cr);

  cairo_set_source_rgba (cr, 1,0.2,0.2,0.6);
  cairo_arc (cr, xc, yc, 0.05, 0, 2*PI); -> works fine
  cairo_fill (cr);
  cairo_set_line_width (cr, 0.03);
  //cairo_arc (cr, xc, yc, radius, angle1, angle1); -> uncomment and you 
will get the error
  cairo_line_to (cr, xc, yc);
  //cairo_arc (cr, xc, yc, radius, angle2, angle2); -> uncomment and you 
will get the error
  cairo_line_to (cr, xc, yc);
  cairo_stroke (cr);

The first two cairo_arc works fine. But the third and fourth not. The 
later have the angle values equal.

I compiled the original code (c) and worked fine in the same system.
Here's the c code:

double xc = 0.5;
double yc = 0.5;
double radius = 0.4;
double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */

cairo_scale (cr, width, height);
cairo_set_line_width (cr, 0.04);

cairo_arc (cr, xc, yc, radius, angle1, angle2);
cairo_stroke (cr);

cairo_set_source_rgba (cr, 1,0.2,0.2,0.6);
cairo_arc (cr, xc, yc, 0.05, 0, 2*M_PI);
cairo_fill (cr);
cairo_set_line_width (cr, 0.03);
cairo_arc (cr, xc, yc, radius, angle1, angle1);
cairo_line_to (cr, xc, yc);
cairo_arc (cr, xc, yc, radius, angle2, angle2);
cairo_line_to (cr, xc, yc);
cairo_stroke (cr);



Here's the c header (arc):
cairo_arc (cairo_t *cr,
       double xc, double yc,
       double radius,
       double angle1, double angle2);

Here's the pascal header (cairo.pp):
procedure cairo_arc(cr:Pcairo_t; xc:double; yc:double; radius:double; 
angle1:double; angle2:double); cdecl; external LIB_CAIRO;

I'm using fpc220 under Ubuntu 07.04

Anyone has a hint on whats going on?

Luiz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairobug.pas
Type: text/x-pascal
Size: 1376 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20071019/a04d1a97/attachment.pas>


More information about the fpc-pascal mailing list