Einzelnen Beitrag anzeigen

Thorben_K

Registriert seit: 22. Okt 2006
Ort: Darmstadt
105 Beiträge
 
Delphi 2006 Professional
 
#1

Pixel der Kreisaussen Linie

  Alt 11. Feb 2007, 12:02
Hallo

ich habe einen Kreis mit einem Mittelpunkt der bekannt ist. Ich brauche jeden Pixel des Kreises, das probleme ist nur das er Kreis ein TShape ist, und ich ja nicht einfach von Top to Top + Heigth durch gehen kann, weil er dann ja zu viel nehmen würde...

Ich habe mir gedacht ich gehe da mit dem Satz des Pythagoras dran, leider geht es so nicht...

Delphi-Quellcode:
function TSchuss.Colision: Boolean;
var
  x, h : LongInt;
  r : LongInt;
  x1, y1, y2 : LongInt;
begin
  result := False;
  r := (height div 2);

  for x := FMitte.X to Left + Width do
  begin
    h := Round(Sqrt((Sqr(x -FMitte.X )) + Sqr(r)));
    x1 := x;
    y1 := FMitte.Y +h;
    y2 := FMitte.Y -h;
    if (getColor(x1, y1)<>FBackGroundColor)or(getColor(x1, y2)<>FBackGroundColor) then
    begin
      result := True;
      Exit;
    end;
  end;

  for x := Left to FMitte.X do
  begin
    h := Round(Sqrt((Sqr(FMitte.X) -x) + Sqr(r)));
    x1 := x;
    y1 := FMitte.Y +h;
    y2 := FMitte.Y -h;
    if (getColor(x1, y1)=FBackGroundColor)or(getColor(x1, y2)=FBackGroundColor) then
    begin
      result := True;
      Exit;
    end;
  end;
end;
Die Farbe finde ich so raus

Delphi-Quellcode:
function TSchuss.GetColor(x, y : LongInt): TColor;
var canvas: TCanvas;
  p : TPoint;
begin
  // vom Koordinatensystem des Formulars ins System des Screens umsteigen
  p := Parent.ClientToScreen(Point(x,y));
  canvas:=TCanvas.Create;
  try
    canvas.Handle:=GetWindowDC(GetDesktopWindow);
    Result:=canvas.Pixels[p.x, p.y];
  finally
    canvas.Free;
  end;
end
Hoffe mir kann einer Helfen, entweder jemand findet den Fehler oder hat ne bessere idee

gruss Thorben

PS: FMitte ist der Mittelpunkt des Kreises von typ TPoint
Thorben
  Mit Zitat antworten Zitat