Mega Code Archive

 
Categories / Delphi / Graphic
 

Grafik çizme işlemi

Codec By GeNiUS ! genius@turkiye.com Unit1.pas unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Image1: TImage; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure grapf; end; var Form1: TForm1; implementation {$R *.DFM} procedure tform1.grapf; var x,l: Integer; y,a: Double; begin Image1.Picture.Bitmap := TBitmap.Create; Image1.Picture.Bitmap.Width := Image1.Width; Image1.Picture.Bitmap.Height := Image1.Height; {These three lines could go in Form1.Create instead} l := Image1.Picture.Bitmap.Width; for x := 0 to l do begin a := (x/l) * 2 * Pi; {Convert position on X to angle between 0 & 2Pi} y := Sin(a); {Your function would go here} y := y * (Image1.Picture.Bitmap.Height / 2); {Scale Y so it fits} y := y * -1; {Invert Y, the screen top is 0 !} y := y + (Image1.Picture.Bitmap.Height / 2); {Add offset for middle 0} Image1.Picture.Bitmap.Canvas.Pixels[Trunc(x), Trunc(y)] := clBlack; end; end; procedure TForm1.Button1Click(Sender: TObject); begin grapf end; end.