Einzelnen Beitrag anzeigen

andiak

Registriert seit: 1. Nov 2007
89 Beiträge
 
#1

Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:12
Ich habe hier in einer Paintbox ein koordinaten kreuz

Delphi-Quellcode:
procedure TForm1.DrawCoords;
var
  i,h: Integer;
begin
  with PaintBox1.Canvas do
    begin
    Pen.Color:=clBlack;
    //Ordinate & Abszisse
    MoveTo(0, PaintBox1.Height div 2);
    LineTo(PaintBox1.Width, PaintBox1.Height div 2);
    MoveTo(PaintBox1.Width div 2, 0);
    LineTo(PaintBox1.Width div 2, PaintBox1.Height);
    //Skalierung
    for i := 1 to 20 do
      begin
      h := i * (PaintBox1.Width div 20);
      MoveTo(h, (PaintBox1.Height div 2) - 3);
      LineTo(h, (PaintBox1.Height div 2) + 3);
      MoveTo((PaintBox1.Width div 2) - 3, h);
      LineTo((PaintBox1.Width div 2) + 3, h);
      end;
    //Beschriftung
    TextOut((PaintBox1.Width div 2) + 3,(PaintBox1.Height div 2) + 1, '0');
    TextOut((PaintBox1.Width div 2) + 48, (PaintBox1.Height div 2) + 6,'1');
     TextOut((PaintBox1.Width div 2) - 55, (PaintBox1.Height div 2) + 6,'-1');
    TextOut((PaintBox1.Width div 2) + 6,(PaintBox1.Height div 2) - 37,'1');
    //Spitzen
    MoveTo(PaintBox1.Width - 5, (PaintBox1.Height div 2) - 5);
    LineTo(PaintBox1.Width, (PaintBox1.Height div 2));
    LineTo(PaintBox1.Width - 5, (PaintBox1.Height div 2) + 5);
    MoveTo((PaintBox1.Width div 2) - 5, 5);
    LineTo((PaintBox1.Width div 2), 0);
    LineTo((PaintBox1.Width div 2) + 5, 5);
  end;
end;
Jetzt gehts um die Punkte auf dem Koordinatenkreuz.
Der Punkt 0/0 liegt ja in der mitte der paintbox
aber 0/0 auf der paintbox ist ja ganz oben links in der ecke

Wie kann ich dies richtig machen?
Die paintbox ist 500x500 pixel groß
  Mit Zitat antworten Zitat