Thema: Delphi Kurve zeichnen

Einzelnen Beitrag anzeigen

mr_emre_d
(Gast)

n/a Beiträge
 
#6

Re: Kurve zeichnen

  Alt 11. Mär 2009, 13:41
Schau dir das folgende Bild an und überlege dir, wie du das lösen kannst
(sehr simpel
http://upload.wikimedia.org/wikipedi...ratic_anim.gif


Falls du das mit funktionen machen willst, wäre dies ein guter Vorschlage:
Delphi-Quellcode:
type
  TFX = function( X: Double ): Double;
..
function MyFunc( X: Double ): Double;
begin
  Result := X*X;
end;

procedure Dot( Pos: TPoint; ACanvas: TCanvas );
begin
  with ACanvas do
  begin
    MoveTo( Pos.X, Pos.Y );
    LineTo( Pos.X + 1, Pos.Y );
    LineTo( Pos.X + 1, Pos.Y + 1 );
    LineTo( Pos.X, Pos.Y + 1 );
    LineTo( Pos.X, Pos.Y );
  end;
end;

procedure DrawFX( Center: TPoint; _Min, _Max, _Accuracy: Integer; ACanvas: TCanvas;
  fx: TFX );
var
  i: Integer;
begin
    for i := _Min*_Accuracy to _Max*_Accuracy do
      Dot( Point( Center.X+i div _Accuracy, Center.X + Round( fx(i / _Accuracy) ) ), ACanvas );
end;

// Zeichnen:
   DrawFX( Point( 100, 100 ), -10, 10, 10, Canvas, MyFunc );
MfG
  Mit Zitat antworten Zitat