Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 12.07.06 21:21 
Im Anhang eine Image-Komponente mit folgenden Canvas-Anweisungen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
with image1.Canvas do
begin
  MoveTo(0,0);
  LineTo(image1.Width div 3,image1.Height);
  MoveTo(0,0);
  LineTo(image1.Width,image1.Height div 3);
end;

Jetzt würde ich gerne die beiden Linien mit einen Kreisbogen verbinden, dass es aussieht wie ein Pizzastück. Nur weiß ich nicht mal im Ansatz wie man das lösen könnte. Hilfe!
Einloggen, um Attachments anzusehen!
_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Mi 12.07.06 21:56 
Hi,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
uses
  Math;
// ...
var
  rot, r: Single;
  x, y: Integer;
begin
  r := Sqrt(Sqr(Image1.Width) + Sqr(Image1.Height div 3));
  rot := 0;
  Image1.Canvas.MoveTo(Image1.Width, Image1.Height div 3);
  repeat
    rot := rot + 0.05;
    x := Round(Cos(GradToRad(rot)) * r);
    y := Round(Sin(GradTorad(rot)) * r);
    if (y >= Image1.Height div 3and (y <= Image1.Height) then
      Image1.Picture.Bitmap.Canvas.LineTo(x, y);
  until rot >= 90
end;


Bei dem "rot := rot + 0.05;" kannst du für "0.05" auch andere Werte nehmen. Je kleiner, desto genauer die Kurve.

Chryzler
LLCoolDave
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 212

Win XP
Delphi 2005
BeitragVerfasst: Mi 12.07.06 21:59 
Gibts für Kreisstücke nicht auch direkt eine Methode der Canvas? Schau mal durch ob du was bei den Methode findest.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 12.07.06 22:00 
user profile iconLLCoolDave hat folgendes geschrieben:
Gibts für Kreisstücke nicht auch direkt eine Methode der Canvas? Schau mal durch ob du was bei den Methode findest.

Es gibt Ellipse, Arc ... Aber ich kann sie nicht so anwenden, dass es passt...

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 12.07.06 23:58 
Hallo,

wenn das Image quadratisch ist, dann:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var r : Integer;
begin
  with image1.Canvas do
    begin
      r := Round(Sqrt(Sqr(Image1.Width) + Sqr(Image1.Height div 3)));
      pie(-r,-r,r,r,image1.Width div 3,image1.Height,image1.Width,image1.Height div 3);
    end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 14:19 
user profile iconLannes hat folgendes geschrieben:
Hallo,

wenn das Image quadratisch ist, dann:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var r : Integer;
begin
  with image1.Canvas do
    begin
      r := Round(Sqrt(Sqr(Image1.Width) + Sqr(Image1.Height div 3)));
      pie(-r,-r,r,r,image1.Width div 3,image1.Height,image1.Width,image1.Height div 3);
    end;

Danke das funktioniert so. ;)
Nur würdest du mir den Quellcode bitte erklären? Es geht nicht um die Befehle sondern mehr um das Wie ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Fr 14.07.06 21:47 
r ist die Länge der beiden Linien (siehe Suche bei Google SATZ DES PYTHAGORAS). Mehr kann ich dir im Moment auch nicht sagen, schau doch mal in der Hilfe bei TCanvas.Pie nach. :wink:
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.07.06 21:54 
user profile iconChryzler hat folgendes geschrieben:
Mehr kann ich dir im Moment auch nicht sagen

Hast du den Code nicht selber geschrieben oder was? Wenn nicht, bennene bitte mal deine Quelle, vielleicht werde ich da ja fündig ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 14.07.06 22:59 
Hallo,

der Kreismittelpunkt deines Kreissektors den Du zeichnen willst liegt in der linken oberen Ecke des TImage,
also bei 0|0.
Die Prozedur Pie
procedure Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Longint);
erwartet in den ersten vier Parametern(X1|Y1 links/oben und X2|Y2 rechts/unten) die Definition des Rechtecks das den Vollkreis umgibt.
Will man ein Rechteck, mit 0|0 als Mittelpunkt, definieren muss man nach links und oben mit Minuswerten, nach unten und rechts mit Pluswerten arbeiten.
Vom Mittelpunkt(0|0) des Rechtecks(Kreises) werden die zwei Seitenbegrenzungen des Sektors in Richtung der Punkte X3|Y3 und X4|Y4 gezeichnet.

Im Anhang befindet sich eine Grafik, der gelbe Bereich ist das TImage.
(ein Bild sagt mehr als tausend Worte :wink: )
Einloggen, um Attachments anzusehen!
_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.07.06 12:51 
Danke, jetzt verstehe ich's.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Sa 15.07.06 14:19 
user profile iconMarco D. hat folgendes geschrieben:
user profile iconChryzler hat folgendes geschrieben:
Mehr kann ich dir im Moment auch nicht sagen

Hast du den Code nicht selber geschrieben oder was? Wenn nicht, bennene bitte mal deine Quelle, vielleicht werde ich da ja fündig ;)

Ich glaube du hast da was verwechselt... :D
Sieh mal genau hin, wer welchen Code geschreiben hat.

Chryzler 8)
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.07.06 14:20 
Jup ich sehs ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot