| Autor |
Beitrag |
ghayatan
Hält's aus hier
Beiträge: 2
|
Verfasst: Di 01.02.05 08:43
Hallo an alle,
ich versuche ein Dreieck auf einem Formular darzustellen. Allerdings nicht einfach als Polygon, sondern ich habe eine Unit dreieck und rufe sie dann im Hauptprogramm auf, das Programm läuft, aber es zeichnet mir nichts. Ich hoffe Ihr könnt mir helfen.
Hier der Code:
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: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88:
| unit Unit2;
interface uses Graphics, Forms, Types;
type TDreieck = class(TObject)
private
public
constructor erzeugen(u,v,w,x,y,z : Integer; f : TForm); procedure zeichnen;
end;
implementation
var z1: integer; Punkt : array[1..3] OF TPoint; cvs : TCanvas;
constructor TDreieck.erzeugen; begin z1:= 0; f.Color := clWhite; Punkt[1].X := u; Punkt[1].Y := v; Punkt[2].X := w; Punkt[2].Y := x; Punkt[3].X := y; Punkt[3].Y := z; cvs := f.Canvas; cvs.Brush.Style := bsClear; cvs.Pen.Mode := pmXOR; zeichnen; end;
procedure TDreieck.zeichnen; begin with cvs do begin Brush.Color := clBlack; Pen.Color := clBlack; Polygon([Point(Punkt[1].X,Punkt[1].Y),Point(Punkt[2].X,Punkt[2].Y),Point(Punkt[3].X,Punkt[3].Y)]); end; end; end.
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private public end;
var Form1: TForm1;
implementation
uses Unit2; var Dreieck1 : TDreieck; {$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin Dreieck1 := TDreieck.erzeugen(10,10,100,200,300,150,form1); Dreieck1.zeichnen; end;
end. |
Ich sag schon mal vielen Dank auch wenn vieleicht keiner mir helfen kann.
Moderiert von Christian S.: Delphi-Tags hinzugefügt.
|
|
st-matze
      
Beiträge: 138
Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
|
Verfasst: Di 01.02.05 09:38
weiss XOR schwarz = weiss
ergo Friesische Nationalflagge:
WeisserAdler auf weissem Grund
//Edit:
entweder läßt du das XOR weg oder du entscheidest dich für Farbkombinationen, die sich nicht gegenseitick aufheben.
|
|
st-matze
      
Beiträge: 138
Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
|
Verfasst: Di 01.02.05 10:21
probier mal aus
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: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76:
| unit Unit2;
interface uses Graphics, Forms, Types;
type TDreieck = class(TObject) private bgC : TColor; fgC : TColor; cvs : TCanvas; Punkt : array[1..3] OF TPoint; procedure Init; public constructor erzeugen(u,v,w,x,y,z : Integer; f : TForm); procedure zeichnen; end;
implementation
procedure TDreieck.Init; begin bgC := clblack; fgC := clwhite; end;
constructor TDreieck.erzeugen; begin Init; f.Color := bgC; Punkt[1].X := u; Punkt[1].Y := v; Punkt[2].X := w; Punkt[2].Y := x; Punkt[3].X := y; Punkt[3].Y := z; cvs := f.Canvas; cvs.Brush.Style := bsClear; zeichnen; end;
procedure TDreieck.zeichnen; var c, fg,bg: longint; begin bg:=ColortoRGB(bgC); fg:=ColortoRGB(fgC); c :=ColortoRGB(fg); c := ((c mod 256) + (bg mod 256)) div 2 + 256 *( (((c div 256) mod 256) + ((bg div 256) mod 256) div 2) + 256 * ( ((c div 65536) +(bg div 65536)) div 2)); with cvs do begin Brush.Color := fg; Pen.Color := c; Polygon([Point(Punkt[1].X,Punkt[1].Y),Point(Punkt[2].X,Punkt[2].Y),Point(Punkt[3].X,Punkt[3].Y)]); end; end;
end. |
|
|
ghayatan 
Hält's aus hier
Beiträge: 2
|
Verfasst: Di 01.02.05 12:20
Vielen vielen dank es funktioniert.
|
|
|