Board index » delphi » Win API Pie Function

Win API Pie Function

Can some body please help with a revise the Win API Pie function. Instead
of using pie with all of these confusing parameter: Pie(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2); i would be grateful if somebody could revise it to
look like this Pie(int x, int y, int width, int height, int startAngle,
int arcAngle);

Please Help

 

Re:Win API Pie Function


Hi James, see my other post on chord.. this also applies to Pie, just
replace all the words "chord" by "pie".

type
  TForm1 = class(TForm)
    pbChord: TPaintBox;
    procedure pbChordPaint(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure Chord_New(Canvas: TCanvas; x, y, width, height, startangle,
arcangle: integer);
var
  X1, Y1, X2, Y2, X3, Y3, X4, Y4: double;
begin
  X1 := x - Width;
  Y1 := y - Height;
  X2 := x + Width;
  Y2 := y + Height;
  X3 := x + cos(StartAngle * pi/180) * Width / 2;
  Y3 := y - sin(StartAngle * pi/180) * Width / 2;
  X4 := x + cos((StartAngle + Arcangle) * pi/180) * Width / 2;
  Y4 := y - sin((StartAngle + Arcangle) * pi/180) * Width / 2;
  if assigned(Canvas) then
    Canvas.Chord(
      round(X1), round(Y1), round(X2), round(Y2),
      round(X3), round(Y3), round(X4), round(Y4));
end;

procedure TForm1.pbChordPaint(Sender: TObject);
begin
  Chord_New(pbChord.Canvas, 50, 50, 40, 30, 45, 180);
end;

Quote
James <ar...@lineone.net> wrote in message news:3c6a8e87$1_2@dnews...

> Can some body please help with a revise the Win API Pie function. Instead
> of using pie with all of these confusing parameter: Pie(HDC hdc, int

nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXRadial1, int
nYRadial1, int nXRadial2, int nYRadial2); i would be grateful if somebody
could revise it to
Quote
> look like this Pie(int x, int y, int width, int height, int startAngle,
> int arcAngle);

> Please Help

Other Threads