Autor Beitrag
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mo 28.06.04 16:14 
Hi,
ich hab jetzt mit Canvas (LineTo) eine Form erstellt.
Aber wie kann ich die Form mit Farbe füllen?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Mo 28.06.04 16:49 
Hallo,

schau dir mal canvas.floodfill an

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mo 28.06.04 18:47 
Irgendwie geht das bei mir nicht.

- 1 Button
- 6 Paintboxes (Die übereinander liegen)

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:
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:
procedure TForm1.Button1Click(Sender: TObject);
var Ax,Bx,Cx,Dx,ex,fx,gx,hx: Integer;
    Ay,By,Cy,Dy,ey,fy,gy,hy: Integer;
begin
  Ax := 50;   Ay := 50;
  Bx := 50;   By := 150;
  Cx := 150;  Cy := 150;
  Dx := 150;  Dy := 50;
  ex := 75;   ey := 75;
  fx := 75;   fy := 175;
  gx := 175;  gy := 175;
  hx := 175;  hy := 75;

  Canvas.FillRect(Rect(0, 0, width, height));

  with Paintbox2 do
  begin
    Canvas.MoveTo(ey, ex);
    Canvas.LineTo(fy, fx);
    Canvas.LineTo(gy, gx);
    Canvas.LineTo(hy, hx);
    Canvas.LineTo(ey, ex);
  end;

  with Paintbox3 do
  begin
    Canvas.MoveTo(Ay, Ax);
    Canvas.LineTo(By, Bx);
    Canvas.LineTo(fy, fx);
    Canvas.LineTo(ey, ex);
    Canvas.LineTo(Ay, Ax);
  end;

  with Paintbox4 do
  begin
    Canvas.MoveTo(By, Bx);
    Canvas.LineTo(fy, fx);
    Canvas.LineTo(gy, gx);
    Canvas.LineTo(cy, cx);
    Canvas.LineTo(By, Bx);
  end;

  with Paintbox5 do
  begin
    Canvas.MoveTo(Dy, Dx);
    Canvas.LineTo(cy, cx);
    Canvas.LineTo(gy, gx);
    Canvas.LineTo(hy, hx);
    Canvas.LineTo(Dy, Dx);
  end;

  with Paintbox6 do
  begin
    Canvas.MoveTo(Ay, Ax);
    Canvas.LineTo(By, Bx);
    Canvas.LineTo(fy, fx);
    Canvas.LineTo(ey, ex);
    Canvas.LineTo(Ay, Ax);
  end;

  with Paintbox1 do
  begin
    Canvas.MoveTo(Ay, Ax);
    Canvas.LineTo(By, Bx);
    Canvas.LineTo(Cy, Cx);
    Canvas.LineTo(Dy, Dx);
    Canvas.LineTo(Ay, Ax);
    Canvas.FloodFill(100, 100, clwhite, fsSurface);
  end;
end;


Eigentlich sollte jetzt die Vordere Fläche (Paintbox1) weis werden und die hinteren verdecken...
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mo 28.06.04 19:07 
Ubs, mein Fehler. Man muss die zu füllende farbe mit
Canvas.Brush.Color := cl***;
angeben. :)