[Lazarus] Fuzzy translations ignored

Howard Page-Clark hdpc at talktalk.net
Thu Sep 18 19:16:55 CEST 2014


On 18/09/2014 17:41, Giuliano Colla wrote:

> Canvas.RadalPie on GTK2 and Windows works only clockwise, but provides a
> very poor image (more like a portion of an octagon that a portion of a
> circle).
> Counterclockwise it generates the image of my previous e-mail.

On Windows here, Pie (RadialPie) works counterclockwise well, using the 
following code example.
I'm sure if you added anitaliasing to improve the rendering quality this 
would be welcomed.

Howard

== code ==

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
   Classes, SysUtils, Forms, Controls, Graphics;

type

   { TForm1 }

   TForm1 = class(TForm)
     procedure FormCreate(Sender: TObject);
     procedure FormPaint(Sender: TObject);
   private
   end;

   TPieRec = record
     percentage: integer; // give pie segments as percentag of whole pie
     color: TColor;
   end;

   TPieArray = array of TPieRec;

   procedure DrawPie(aCanvas: TCanvas; aCircleRect: TRect; pa: TPieArray);

var
   Form1: TForm1;

implementation

procedure DrawPie(aCanvas: TCanvas; aCircleRect: TRect; pa: TPieArray);
var
   angles: array of integer;
   lastAngle: integer = 0;
   i: Integer;
begin
   SetLength(angles, Length(pa));
   for i:=0 to High(pa) do begin
     angles[i]:=trunc(pa[i].percentage * 57.60);
     aCanvas.Brush.Color:=pa[i].color;
     aCanvas.RadialPie(aCircleRect.Left, aCircleRect.Top, 
aCircleRect.Right, aCircleRect.Bottom,
                       lastAngle, angles[i]);
     Inc(lastAngle, angles[i]);
   end;
end;

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
end;

procedure TForm1.FormPaint(Sender: TObject);
var
   example: TPieArray;
   circleRect: TRect;
begin
   circleRect:=Rect(10,10,110,110);
   SetLength(example, 4);
   example[0].percentage:=30; example[0].color:=clBlue;
   example[1].percentage:=10; example[1].color:=clRed;
   example[2].percentage:=20; example[2].color:=clYellow;
   example[3].percentage:=40; example[3].color:=clMoneyGreen;
   DrawPie(Canvas, circleRect, example);
end;

end.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: pieExample.png
Type: image/png
Size: 8312 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140918/10f1ea7c/attachment-0003.png>


More information about the Lazarus mailing list