Recent

Author Topic: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)  (Read 1920 times)

Roland57

  • Hero Member
  • *****
  • Posts: 588
    • msegui.net
The attached example (an arc filled with gradient) doesn't produce the same output, depending on whether we link to fpGUI or to LCL units.

You can use the included Makefile as follows:

Code: Bash  [Select][+][-]
  1. make arc
  2. make arc LCL=1

(You need to edit paths according to your installation.)
« Last Edit: February 17, 2026, 09:47:21 am by Roland57 »
My projects are on Codeberg.

wp

  • Hero Member
  • *****
  • Posts: 13433
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #1 on: February 16, 2026, 02:15:23 pm »
In the LCL-AggPas, the arc is painted with the "strokeOnly" parameter, while in Graeme's it has "FillAndStroke". - I think I can change this in the LCL. But on the other hand, Delphi's and Lazarus' and fcl-Image's Arc draw the outline only, there's a dedication method for the filled arc ("Chord"). Maybe the most flexible option would be to provide an optional additional DrawPathFlag parameter (FillOnly, StrokeOnly, FillAndStroke, FillWithLineColor)

The other difference is that the LCL version seems to draw the arc in clockwise direction although the missing ccw parameter has the value true, i.e. counter-clockwise. The problem is that aggpas, in acc2d.arc, suddenly sets the ccw parameter to false (clockwise). Not sure if this is intentional (if yes, why didn't they default ccw to false in the first place?). Graeme seems to have decided to define this as a bug because his code exchanges the "start" and "sweep" angle parameters and thus makes the clockwise to a counter-clickwise. I personally think this way of dealing with the issue is confusing, and I tend to remove the ccw="false" argument from Agg2D.arg so that the default value of "true" will be used again.
« Last Edit: February 16, 2026, 04:33:07 pm by wp »

Roland57

  • Hero Member
  • *****
  • Posts: 588
    • msegui.net
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #2 on: February 17, 2026, 10:18:45 am »
Thank you Werner for your investigation.

Probably I will create an issue in fpGUI repository, to be sure that Graeme see this discussion.

Meanwhile I made a more complete test program.
My projects are on Codeberg.

Graeme

  • Hero Member
  • *****
  • Posts: 1496
    • Graeme on the web
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #3 on: February 17, 2026, 11:04:15 am »
intentional (if yes, why didn't they default ccw to false in the first place?). Graeme seems to have decided to define this as a bug because his code exchanges the "start" and "sweep" angle parameters and thus makes the clockwise to a counter-clickwise.

I'll have to check the git history for clues - it's been years. I do recall that because fpGUI used GDI and X11 api's years before AggCanvas was added, I adapted some agg2d code to match the behavior of GDI and X11 to some degree. That might have been one such case. In hindsight - if that was so - there definitely are better ways to handle that.

If I get a moment, I'll have a look.

G
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

cdbc

  • Hero Member
  • *****
  • Posts: 2687
    • http://www.cdbc.dk
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #4 on: February 17, 2026, 05:02:28 pm »
Hi Roland
<offtopic> Sorry for the break in
Sorry mate, my github broke over the last couple of days :(
So, here it is, can you please fork it as you see fit =^
Have fun...

Note: this package should compile with FPC 3.2.2 out of the box :)
No external dependencies, like before  ;D
</offtopic>
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Graeme

  • Hero Member
  • *****
  • Posts: 1496
    • Graeme on the web
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #5 on: February 19, 2026, 11:36:17 pm »
In the LCL-AggPas, the arc is painted with the "strokeOnly" parameter, while in Graeme's it has "FillAndStroke".

I had a quick look. Regardless if there is FillAndStroke in the Arc() method. If you call agg.noFill before calling Arc(), it will not fill the arc. Using FillAndStroke in all the shape APIs just means I don't need to add additional parameters to all the methods, and you can still control if Arc() will render with stroke-only, fill-only or both.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Roland57

  • Hero Member
  • *****
  • Posts: 588
    • msegui.net
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #6 on: February 20, 2026, 12:16:11 am »
Thank you for the investigation Graeme.

I had a quick look. Regardless if there is FillAndStroke in the Arc() method. If you call agg.noFill before calling Arc(), it will not fill the arc. Using FillAndStroke in all the shape APIs just means I don't need to add additional parameters to all the methods, and you can still control if Arc() will render with stroke-only, fill-only or both.

I would agree on that point.

On the second point I would agree with @wp.

If it were my code, I would remove the default parameter value in the low level function:

Code: Pascal  [Select][+][-]
  1. // agg_arc.pas
  2. constructor arc.Construct(x ,y ,rx ,ry ,a1 ,a2 : double; ccw : boolean = true );

And I would put parameters in correct order here:

Code: Pascal  [Select][+][-]
  1. // agg_2D.pas
  2. procedure Agg2D.arc(cx ,cy ,rx ,ry ,start ,sweep : double );
  3. var
  4.  ar : {bezier_}agg_arc.arc;
  5.  
  6. begin
  7.   // ...
  8.  ar.Construct(cx ,cy ,rx ,ry ,sweep, start,false ); // <---

And change the boolean value (?).

While I was working on my clock example, I noticed that agg_2D and Agg2D use different convention: trigonometric for the one, antitrigonometric for the other. If it is a clear decision, why not.

Anyway please find an agreement with @wp, so that we can go forward.  ;)
« Last Edit: February 20, 2026, 12:22:56 am by Roland57 »
My projects are on Codeberg.

Graeme

  • Hero Member
  • *****
  • Posts: 1496
    • Graeme on the web
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #7 on: February 20, 2026, 12:38:34 am »
Yeah, I didn't mention in my earlier message. I do agree about the inconsistent default, the unused `ccw` parameter (it never set the field variable), and swapped angle arguments do seem wrong.

It will all be fixed very shortly. :-)
« Last Edit: February 20, 2026, 12:41:20 am by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

wp

  • Hero Member
  • *****
  • Posts: 13433
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #8 on: February 20, 2026, 12:55:57 am »
Modified the arc procedure in the LCL's aggpas to use the FillAndStroke parameter as suggested by Graeme. Modified the Construct method such that the ccw argument can be true, also in TAggFPCanvas.Arc. Renamed some misleading parameters (endangle instead of sweep) and corrected some comments (counter-clockwise vs clockwise). Added an incompatibility note to the Laz 5.0 release notes about the FillAndStroke parameter (https://wiki.freepascal.org/Lazarus_5.0_release_notes#aggpas_incompatibility).

Roland57

  • Hero Member
  • *****
  • Posts: 588
    • msegui.net
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #9 on: February 20, 2026, 09:26:27 am »
@wp

Tested your changes successfully. Thanks!
My projects are on Codeberg.

Graeme

  • Hero Member
  • *****
  • Posts: 1496
    • Graeme on the web
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #10 on: February 22, 2026, 12:55:18 pm »
For fpGUI's FillArc() which is totally the wrong name - so we learn.  :D Anyway, I noticed when AggCanvas was enabled, it didn't render a "filled pie" like GDI and X11 did. I created a new agg_2D.pas implementation which now matches the other platforms.

I'll start the deprecation of Canvas.FillArc() to become Pie() or something, so it more accurately reflects the implementation intent.

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Roland57

  • Hero Member
  • *****
  • Posts: 588
    • msegui.net
Re: [AGGPas] Difference between fpGUI and LCL (arc method of agg_2D unit)
« Reply #11 on: March 14, 2026, 04:36:02 pm »
Hello AGG friends.

The problem is still not (totally) solved.

Look at this arc from 0 to PI / 2.

For me, I would say that the LCL version is right.

@Graeme
Do you agree?
« Last Edit: March 15, 2026, 07:01:55 am by Roland57 »
My projects are on Codeberg.

 

TinyPortal © 2005-2018