AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Minipaint - Kreis von Mittelpunkt aufziehen
Thema durchsuchen
Ansicht
Themen-Optionen

Minipaint - Kreis von Mittelpunkt aufziehen

Offene Frage von "co0kie"
Ein Thema von co0kie · begonnen am 10. Dez 2005 · letzter Beitrag vom 11. Feb 2008
 
Benutzerbild von jamma-markus
jamma-markus

Registriert seit: 16. Okt 2004
Ort: Kempen
58 Beiträge
 
#24

Re: Minipaint - Kreis von Mittelpunkt aufziehen

  Alt 16. Dez 2005, 14:05
Delphi-Quellcode:
  private
    { Private-Deklarationen }
    mausgedrueckt : boolean;
    x_start, y_start, x_alt, y_alt,
      radius, radius_alt,
      breite, hoehe, breite_alt, hoehe_alt,
      quadrat_x, quadrat_y,
      max, laenge_alt : integer;
    bg_color, fg_color, fill_color : TColor;
    deckend : TBrushStyle;
    function vorzeichen(a : integer): integer;

function TMain.vorzeichen(a : integer): integer;
begin
  if a < 0
  then Result := -1
  else Result := +1;
end;

procedure TMain.im_pictureMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  mausgedrueckt := true;
  with im_picture.Canvas do
    begin
      case Main.Tag of
        8 : begin
              x_start := x;
              y_start := y;
              x_alt := x;
              y_alt := y;

              breite := x - X_start;
              hoehe := y - y_start;

              if breite > hoehe
              then
                begin
                  quadrat_x := x_start + breite;
                  quadrat_y := y_start + breite * vorzeichen(hoehe);
                end
              else
                begin
                  quadrat_x := x_start + hoehe * vorzeichen(breite);
                  quadrat_y := y_start + hoehe;
                end;
           end;
      end;
    end;
end;

procedure TMain.im_pictureMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  with im_picture.Canvas do
    begin
      if mausgedrueckt
      then
        case Main.Tag of
          8 : begin
              pen.Color := clSilver;
              Pen.Style := psDot;
              Brush.Style := bsClear;

              Pen.Mode := pmNotXor;

              Rectangle(x_start, y_start, quadrat_x, quadrat_y);

              breite := x - X_start;
              hoehe := y - y_start;

              if breite > hoehe
              then
                begin
                  quadrat_x := x_start + breite;
                  quadrat_y := y_start + breite * vorzeichen(hoehe);
                end
              else
                begin
                  quadrat_x := x_start + hoehe * vorzeichen(breite);
                  quadrat_y := y_start + hoehe;
                end;

              Rectangle(x_start, y_start, quadrat_x, quadrat_y);

              pen.Style := psSolid;
              pen.Color := fg_color;

            end;
        end;
    end;
end;

procedure TMain.im_pictureMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  with im_picture.Canvas do
    begin
      if not bt_hand.Enabled
      then mausgedrueckt := false;
      if mausgedrueckt
      then
        begin
          case Main.Tag of
            8 : begin
                  pen.Mode := pmCopy;
                  pen.Style := psSolid;
                  pen.Color := fg_color;
                  Brush.Color := bg_color;
                  Brush.Style := deckend;

                  breite := x - X_start;
                  hoehe := y - y_start;

                  if breite > hoehe
                  then
                    begin
                      quadrat_x := x_start + breite;
                      quadrat_y := y_start + breite * vorzeichen(hoehe);
                    end
                  else
                    begin
                      quadrat_x := x_start + hoehe * vorzeichen(breite);
                      quadrat_y := y_start + hoehe;
                    end;

                  Rectangle(x_start, y_start, quadrat_x, quadrat_y);

                end;
          end;
        end;
    end;
  mausgedrueckt := false;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:13 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz