Autor Beitrag
navarro2010
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25
Erhaltene Danke: 1



BeitragVerfasst: Sa 21.05.11 12:13 
Hallo,
ich möchte mit Delphi mehrere Kreise zeichnen, die unterschiedliche Größen haben, jedoch den gleichen Mittlepunkt. Es soll eine Art Fadenkreuz geben.
Hier mein Versuch:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure Image1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Image1Click(Sender: TObject);
  var x:integer;
begin
  x:=0;
  repeat
  Form1.Canvas.Ellipse(Form1.Width div 2-x, Form1.Height div 2-x, Form1.Width div 2+x, Form1.Height div 2+x);
  Form1.Canvas.Ellipse(Form1.Width div 2-2*x, Form1.Height div 2-2*x, Form1.Width div 2+2*x, Form1.Height div 2+2*x);
  x:=x+1;
  until x=73;

end;

end.


Ich glaube, dass zwar mehrere Kreise gezeichnet werden, die aber dann vom größten Kreis überdeckt werden. wie kann ich das ändern?
Danke für die Hilfe
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Sa 21.05.11 12:45 
Hallo,

Du musst den brush.style passend festlegen:
www.greatis.com/delp...ics-brushstyles.html

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Image1Click(Sender: TObject);
  var x:integer;
begin
  x:=0;
  Form1.Canvas.Brush.Style :=bsClear;
  repeat
     with Form1.Canvas do
       begin
       Ellipse(Form1.Width div 2-x, Form1.Height div 2-x, Form1.Width div 2+x, Form1.Height div 2+x);
       Ellipse(Form1.Width div 2-2*x, Form1.Height div 2-2*x, Form1.Width div 2+2*x, Form1.Height div 2+2*x);
       end;
    inc(x);
  until x=73;

end;


Gruß Horst

Für diesen Beitrag haben gedankt: navarro2010
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 21.05.11 12:46 
Du könntest das Ganze von oben Herunterlaufen lassen. Dann wird der größte Kreis als erstes gemalt ;)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  x:=73;
  repeat
  Form1.Canvas.Ellipse(Form1.Width div 2-x, Form1.Height div 2-x, Form1.Width div 2+x, Form1.Height div 2+x);
  Form1.Canvas.Ellipse(Form1.Width div 2-2*x, Form1.Height div 2-2*x, Form1.Width div 2+2*x, Form1.Height div 2+2*x);
  x:=x-1;
  until x<=0;

Für diesen Beitrag haben gedankt: navarro2010
navarro2010 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25
Erhaltene Danke: 1



BeitragVerfasst: Sa 21.05.11 13:02 
Danke für eure Hilfe.
Wenn ich das Ganze so mache taucht allerdings noch das Problem auf, dass in der Mitte die Kreise so eng aneinander liegen, dass eigentlich ein schwarzer Punkt ist.
Was kann ich noch ändern?
Gerd Kayser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 632
Erhaltene Danke: 121

Win 7 32-bit
Delphi 2006/XE
BeitragVerfasst: Sa 21.05.11 13:43 
user profile iconnavarro2010 hat folgendes geschrieben Zum zitierten Posting springen:
Wenn ich das Ganze so mache taucht allerdings noch das Problem auf, dass in der Mitte die Kreise so eng aneinander liegen, dass eigentlich ein schwarzer Punkt ist.

Dann setz halt einen größeren Abstand, z. B.:
ausblenden Delphi-Quelltext
1:
 x := x - 5;					
beastofchaos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 247
Erhaltene Danke: 4



BeitragVerfasst: Sa 21.05.11 13:55 
(Genau, dann könnte man der Schönheits halber auch noch die Funktion Dec() benutzen :P

-> Dec(x, 5);

Gruß, Thomas