Autor Beitrag
Langa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN XP

BeitragVerfasst: Mo 13.06.05 21:58 
also ich will einen kreis malen aber in einem timer stehen soll und quasi pixel für pixel gemalt werden soll weil ein punkt den kreis malen soll ich hab das schon geschaft mit paintbox1.canvas.pixels[x,y]:=clblack; die kreisbahn abzufahren aber wie kann ich es machen das die eingefärbten pixel wie gespeichert werden und nicht wieder 'verschwinden' und der nächste pixel eingefärbt wird sondern nach einem umlauf halt dann der ganz kreis zu sehen ist aber auch nach einem umlauf wider von neuem beginnt

hoffe mir kann jemand helfen :cry:
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 22:02 
poste mal deinen kreis-code, vermutlich hast du den falschen Mode beim Pen eingestellt

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Langa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN XP

BeitragVerfasst: Mo 13.06.05 22:12 
hm also ein schieber soll den kreis bzw ellipse zeichnen

ausblenden 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:
procedure TForm1.Timer1Timer(Sender: TObject);

begin
  x0:=160;
  y0:=160;
  winkel:=winkel+1;
  if winkel>360 then winkel:=0;
  winkelrad:=winkel/180*pi;
  form1.paintbox1.Canvas.Brush.Color:=clBtnFace;
  form1.paintbox1.canvas.Pen.Color:=clbtnface;
  form1.PaintBox1.Canvas.Rectangle(0,16,330,330);
  form1.paintbox1.Canvas.Pen.Color:=clblack;
  form1.PaintBox1.Canvas.MoveTo(26,160);
  form1.PaintBox1.Canvas.LineTo(320,160);
  form1.PaintBox1.canvas.MoveTo(160,26);
  form1.PaintBox1.Canvas.LineTo(160,320);
  l:=strtoint(edit2.text);
  r:=strtoint(edit1.text);
  x:=round(cos(winkelrad)*l+x0);
  y:=round(sin(winkelrad)*l+y0);
  yp:=round(y0+(1-r/l)*(y-y0));
  xp:=round(x0+r/l*(x-x0));
  form1.PaintBox1.Canvas.Ellipse(x-5,y0-5,x+5,y0+5);
  form1.PaintBox1.Canvas.Ellipse(x0-5,y-5,x0+5,y+5);
  form1.PaintBox1.Canvas.Ellipse(xp-5,yp-5,xp+5,yp+5);
  form1.PaintBox1.Canvas.pen.Color:=clred;
  form1.PaintBox1.Canvas.MoveTo(x,y0);
  form1.PaintBox1.Canvas.LineTo(x0,y);
  form1.PaintBox1.Canvas.Pen.Color:=clblack;


also soll er den von dem punkt auf ner linie erzeugten bahn malen

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 22:21 
is klar, denn mit rectangle löscht du ja alles was schon gezeichnet wurde.

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:
var
  Form1: TForm1;
  x0,y0,l,r,x,y,yp,xp,winkel:integer;
  winkelrad:single;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  x0:=160;
  y0:=160;
  winkel:=winkel+1;
  if winkel>360 then winkel:=0;
  winkelrad:=winkel/180*pi;
  with form1.PaintBox1.Canvas do begin
    Brush.Color:=clBtnFace;
    Pen.Color:=clbtnface;
//    pen.mode := pmCopy;
 //   Rectangle(0,16,330,330);
    Pen.Color:=clblack;
    MoveTo(26,160);
    LineTo(320,160);
    MoveTo(160,26);
    LineTo(160,320);
    l:=20;
    r:=50;
    x:=round(cos(winkelrad)*l+x0);
    y:=round(sin(winkelrad)*l+y0);
    yp:=round(y0+(1-r/l)*(y-y0));
    xp:=round(x0+r/l*(x-x0));
    Ellipse(x-5,y0-5,x+5,y0+5);
    Ellipse(x0-5,y-5,x0+5,y+5);
    Ellipse(xp-5,yp-5,xp+5,yp+5);
    pen.Color:=clred;
    MoveTo(x,y0);
    LineTo(x0,y);
    Pen.Color:=clblack;
  end;
end;

end.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Langa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN XP

BeitragVerfasst: Mo 13.06.05 22:32 
ja aber trotzdem muss ja geziegt und bei jedem neuen winkel die neue grafik gezeigt werden
aber ich will ja das die mit dem befehl canvas.pixels[..]; eingefärbten pixel zu sehen bleiben

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:
procedure TForm1.Timer1Timer(Sender: TObject);

begin
  x0:=160;
  y0:=160;
  winkel:=winkel+1;
  if winkel>360 then winkel:=0;
  winkelrad:=winkel/180*pi;
  form1.paintbox1.Canvas.Brush.Color:=clBtnFace;
  form1.paintbox1.canvas.Pen.Color:=clbtnface;
  form1.PaintBox1.Canvas.Pen.mode:=pmcopy;
  form1.PaintBox1.Canvas.Rectangle(0,16,330,330);
  form1.paintbox1.Canvas.Pen.Color:=clblack;
  form1.PaintBox1.Canvas.MoveTo(26,160);
  form1.PaintBox1.Canvas.LineTo(320,160);
  form1.PaintBox1.canvas.MoveTo(160,26);
  form1.PaintBox1.Canvas.LineTo(160,320);
  l:=strtoint(edit2.text);
  r:=strtoint(edit1.text);
  x:=round(cos(winkelrad)*l+x0);
  y:=round(sin(winkelrad)*l+y0);
  yp:=round(y0+(1-r/l)*(y-y0));
  xp:=round(x0+r/l*(x-x0));
  form1.PaintBox1.Canvas.Ellipse(x-5,y0-5,x+5,y0+5);
  form1.PaintBox1.Canvas.Ellipse(x0-5,y-5,x0+5,y+5);
  form1.PaintBox1.Canvas.Ellipse(xp-5,yp-5,xp+5,yp+5);
  form1.PaintBox1.Canvas.pen.Color:=clred;
  form1.PaintBox1.Canvas.MoveTo(x,y0);
  form1.PaintBox1.Canvas.LineTo(x0,y);
  form1.PaintBox1.Canvas.Pen.Color:=clblack;
  form1.PaintBox1.Canvas.Pixels[xp,yp]:=clblack;


end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconraziel: Beiträge zusammengefasst.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 22:35 
in dem code von dir kommt pixels nirgends vor :roll:

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Langa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN XP

BeitragVerfasst: Mo 13.06.05 22:36 
letzte zeile vorm end
färbt den pixel ein
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 22:42 
aha, der eine pixel in der mitte des sich um den nullpunkt kreisenden kreises ?

was soll man vom rest noch sehen ?

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Langa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN XP

BeitragVerfasst: Mo 13.06.05 22:48 
hab dir das programm mal geschickt es soll dann also beim umlauf die entstehende bahn von dem noch zu sehenden schieber gezeichnet werden
also so wie es im code steht soll es noch zu sehen sein
und der schieber ist dann also der stift also der punkt mit dem koordinaten xp und yp
der es malt
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 23:37 
dass problem ist halt dass du mit dem rectangle alles löscht was vorher gezeichnet wurde, also auch den pixel

ich hab das nun in 2 bitmaps getrennt, in einem wird der gezeichnete kreis gespeichert, in dem anderen der rest:

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:
procedure TForm1.Timer1Timer(Sender: TObject);

begin
  x0:=160;
  y0:=160;
  winkel:=winkel+1;
  if winkel>360 then winkel:=0;
  winkelrad:=winkel/180*pi;

  l:=strtoint(edit2.text);
  r:=strtoint(edit1.text);
  x:=round(cos(winkelrad)*l+x0);
  y:=round(sin(winkelrad)*l+y0);
  yp:=round(y0+(1-r/l)*(y-y0));
  xp:=round(x0+r/l*(x-x0));


  with bitmap1.Canvas do begin
    Brush.Color:=clBtnFace;
    Pen.Color:=clbtnface;
    Rectangle(0,16,w,h);
    Pen.Color:=clblack;
    MoveTo(26,160);
    LineTo(320,160);
    MoveTo(160,26);
    LineTo(160,320);
    Ellipse(x-5,y0-5,x+5,y0+5);
    Ellipse(x0-5,y-5,x0+5,y+5);
    Ellipse(xp-5,yp-5,xp+5,yp+5);
    pen.Color:=clred;
    MoveTo(x,y0);
    LineTo(x0,y);
 //   CopyRect(paintbox1.Canvas.ClipRect ,paintbox1.Canvas,paintbox1.Canvas.ClipRect)
//  paintbox1.Canvas.Brush.Style := bsclear;
  end;

  paintbox1.Canvas.Draw(0,0,bitmap1);
  bitmap2.Canvas.Pen.Color:=clblack;
  bitmap2.Canvas.Pixels[xp,yp]:=clblack;
//  paintbox1.Canvas.Draw(0,0,bitmap2);
  paintbox1.Canvas.CopyMode:= cmSrcAnd  ;
  paintbox1.Canvas.CopyRect(rect(0,0,w,h) ,bitmap2.Canvas, rect(0,0,w,h));
  paintbox1.Canvas.CopyMode := cmSrcCopy  ;
end;


rest vom code kommt per pn

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Langa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN XP

BeitragVerfasst: Di 14.06.05 10:03 
kannst du mir dann mal sagen wo und wie im code ich dann den kreis auch löschen kann das wenn amn reset macht nur der neue kreis zu sehen ist????
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 14.06.05 12:32 
klar, einfach bitmap2.canvas.fillrect(rect(0,0,w,h,)); (erst pen color setzen)

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...