Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-10

Trouble converting to pascal sample examples of cairo

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luiz Americo Pereira Camara

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

F x L
to Luiz Americo Pereira Camara

Hi.
I'm getting a warning error in program with a new FPC 2.2.0 because the socket library was obsolete. The recomended option is ssocket library but I did'nt find this documentation. Could you help me ?
Thanks,
FxL

_________________________________________________________________ Conheça o Windows Live Spaces, a rede de relacionamentos conectada ao Messenger! http://spaces.live.com/signup.aspx

Marco van de Voort
to F x L
I'm getting a warning error in program with a new FPC 2.2.0 because the socket library was obsolete. The recomended option is ssocket library but I did'nt find this documentation.

It's not the sockets unit that is obsolete, but just a few of the older (1.0.x) functions are deprecated.

Solution: use the "new" ones that are in there since 2003, and where released in 2.0. They can be recognized by the fp prefix.