AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Canvas Zeichnung drehen
Thema durchsuchen
Ansicht
Themen-Optionen

Canvas Zeichnung drehen

Ein Thema von Gnaaman · begonnen am 1. Jun 2006 · letzter Beitrag vom 2. Jun 2006
 
hboy

Registriert seit: 16. Jan 2004
364 Beiträge
 
#15

Re: Canvas Zeichnung drehen

  Alt 1. Jun 2006, 20:20
weil ich heut meinen guten Tag hab


Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,Math;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;

    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen } 
  public
    { Public-Deklarationen }
  end;

type TMann2 = class
  xpos,ypos : integer;
  a : single;
  axis: TPoint;
  constructor create(Mx,My :integer);
  procedure zeichnen(Winkel: single = 0);
end;


var
  Form1: TForm1;
  Mann2: TMann2;

implementation

{$R *.dfm}

function RotateCCW(position,axis: TPoint; alpha: single): TPoint;
var relative: TPoint;
begin
  relative := Point(position.x - axis.x,position.y - axis.y);
  result.x := axis.x + round(relative.x* cos(alpha) + relative.y*sin(alpha));
  result.y := axis.y + round(relative.x*-sin(alpha) + relative.y*cos(alpha));
end;

procedure TMann2.zeichnen(Winkel: single = 0);
var
  p: TPoint;
begin
  a := winkel;
  form1.Repaint;
  p := RotateCCW(Point(xpos,ypos+10),axis,a);
  Form1.Canvas.Ellipse(p.x-10,p.y-10,p.x+10,p.y+10);



  p := RotateCCW(Point(xpos,ypos+20),axis,a);
  Form1.Canvas.Moveto(p.x,p.y);
  p := RotateCCW(Point(xpos,ypos+50),axis,a);
  Form1.Canvas.LineTo(p.x,p.y);
  p := RotateCCW(Point(xpos+10,ypos+70),axis,a);
  Form1.Canvas.LineTo(p.x,p.y);
  p := RotateCCW(Point(xpos,ypos+50),axis,a);
  Form1.Canvas.Moveto(p.x,p.y);
  p := RotateCCW(Point(xpos-10,ypos+70),axis,a);
  Form1.Canvas.LineTo(p.x,p.y);
  p := RotateCCW(Point(xpos,ypos+25),axis,a);
  Form1.Canvas.Moveto(p.x,p.y);
  p := RotateCCW(Point(xpos-5,ypos+45),axis,a);
  Form1.Canvas.LineTo(p.x,p.y);
  p := RotateCCW(Point(xpos,ypos+25),axis,a);
  Form1.Canvas.Moveto(p.x,p.y);
  p := RotateCCW(Point(xpos+5,ypos+45),axis,a);
  Form1.Canvas.LineTo(p.x,p.y);
end;

constructor TMann2.create (Mx,My:integer);
begin
  inherited Create; // macht man nunmal so ;)
  xpos:=Mx;
  ypos:=My;
  a := 0;
  axis := Point(xpos -10, ypos + 70);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Mann2.Zeichnen;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  while mann2.a < pi/2 do
  begin
    mann2.a := mann2.a + 0.05;
    mann2.zeichnen(mann2.a);
    sleep(50);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Mann2:=TMann2.create(400,300);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  while mann2.a > 0 do
  begin
    mann2.a := mann2.a - 0.05;
    mann2.zeichnen(mann2.a);
    sleep(50);
  end;
end;

end.

aber jetzt bitte keine Fragen mehr. ich hab feierabend
Power is nothing without TControl
  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 03:08 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