Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#16

AW: Zeichnen auf Canvas und ZOrder bzw. Übermalen

  Alt 2. Apr 2015, 10:56
Hallo Emil, wer zuletzt malt malt zuletzt, das trifft auch für Brush.Style zu (Siehe Setter von TBrush).

Delphi-Quellcode:
    // ergibt bsClear;
    Bitmap.Canvas.Brush.Color := clInfoBK;
    Bitmap.Canvas.Brush.Style := bsClear;

    // ergibt bsSolid;
    Bitmap.Canvas.Brush.Style := bsClear;
    Bitmap.Canvas.Brush.Color := clInfoBK; // ***
Color und Style beeinflussen sich auch gegenseitig.
Danke!
Verstehe aber nicht wo ich es einsetzen soll.
Funktioniert einfach nicht.

Zuerst wird PrepareScale aufgerufen aus der Draw function.
Delphi-Quellcode:
procedure TGraph.PrepareScale;
var
  gray: Integer;
begin

  If ScaleMax = 0 Then
    ScaleMax := 1;

  Aspect := Bitmap.Width / Bitmap.Height;

  yMin := -ScaleMax;
  yMax := ScaleMax;
  xMin := -ScaleMax * Aspect;
  xMax := ScaleMax * Aspect;

  Bo := 20;
  BoLeft := Bo;
  BoTop := Bo;
  BoRight := Bo;
  BoBottom := Bo;

  Fact;

  Bitmap.Canvas.brush.Color := $00E0FFFF;
  // Hintergrund löschen
  Bitmap.Canvas.FillRect(Bitmap.Canvas.ClipRect);

  if HelpIsOn then
    DrawHelp;

  gray := 200;
  gray := RGB(gray, gray, gray);
  Bitmap.Canvas.Pen.Color := gray;

  // Koordinatenkreuz
  Bitmap.Canvas.MoveTo(xxc(xMin), yyc(0));
  Bitmap.Canvas.LineTo(xxc(xMax), yyc(0));
  Bitmap.Canvas.MoveTo(xxc(0), yyc(yMin));
  Bitmap.Canvas.LineTo(xxc(0), yyc(yMax));

  // Brush löschen
  Bitmap.Canvas.Brush.Style:= bsClear;

  // Kreis zeichnen
  DrawEllipseFromCenter(Bitmap.Canvas, xxc(Physics.x0), yyc(Physics.y0), trunc(xFact * Physics.L0));

  Bitmap.Canvas.Pen.Color := clblack;
  //Rechteck von links oben nach rechts unten
  Bitmap.Canvas.Rectangle(xxc(xMin), yyc(yMin), xxc(xMax), yyc(yMax));
end;
dann die Draw selbst.
Delphi-Quellcode:
procedure TGraph.Draw;
begin

  Bitmap.Canvas.Font.Color := clblack;

  PrepareScale;

  // Pendel Linie
  If Physics.D <> 0 then
  begin
    Bitmap.Canvas.Pen.Color := clblack;
    Bitmap.Canvas.MoveTo(xxc(Physics.x0), yyc(Physics.y0));
    Bitmap.Canvas.LineTo(xxc(Physics.x1), yyc(Physics.y1));
  end;

  // Pendel Center Punkt
  Bitmap.Canvas.Brush.Style:= bsclear;
  Bitmap.Canvas.Pen.Width := 3;
  Bitmap.Canvas.Pen.Mode := pmMergePenNot;

  DrawEllipseFromCenter(Bitmap.Canvas, xxc(Physics.x0), yyc(Physics.y0), round(Physics.r0 * xFact));

  // Pendel (Ball)
  Bitmap.Canvas.brush.Color := clred;
  Bitmap.Canvas.Pen.Width := 2;
  DrawEllipseFromCenter(Bitmap.Canvas, xxc(Physics.x1), yyc(Physics.y1), round(Physics.r1 * xFact));

  Bitmap.Canvas.Pen.Width := 1;

  // vom Bitmap auf das Canvas kopieren
  BitBlt(PaintFrame.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height, Bitmap.Canvas.Handle, 0, 0, srccopy);
end;

pmMergeNotPen > Combination of canvas background color and inverse of pen Color.
Sorgt dafür das der gro0e Graue Kreis überdeckt wird.
Was soll da falsch sein (oder vergessen) das es nicht geht.

gruss

Geändert von EWeiss ( 2. Apr 2015 um 11:01 Uhr)
  Mit Zitat antworten Zitat