Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Quadrat 90° gedreht (https://www.delphipraxis.net/64427-quadrat-90%B0-gedreht.html)

netscanner 3. Mär 2006 14:08


Quadrat 90° gedreht
 
Hallo,

dass ich jetzt ein um 90° gedrehtes Quadrat bekomme habe ich jetzt das hier gemacht:

Delphi-Quellcode:
image1.Canvas.MoveTo(120,40);
image1.Canvas.lineTo(200,120);

image1.Canvas.MoveTo(200,120);
image1.Canvas.lineTo(120,200);

image1.Canvas.MoveTo(120,200);
image1.Canvas.lineTo(40,120) ;

image1.Canvas.MoveTo(40,120);
image1.Canvas.lineTo(120,40) ;
geht das auch einfacher z.b. wie der rectangle code?
wenn möglich antworten mit code besispielen - danke ^^

ichbins 3. Mär 2006 14:13

Re: Quadrat 90° gedreht
 
dreh mal bitte ein Quadrat um 90°... lol ich denke mal du meinst 45° *g*

ich denke das ist bereits die einfachste Lösung. Du könntest nur noch das Quadrat per Rectangle erzeugen und dann einen Algorithmus verwenden der das Bild um 45° dreht, aber ob das schneller geht...

netscanner 3. Mär 2006 14:16

Re: Quadrat 90° gedreht
 
ja gut 45° sorry ^^
ich hab mal was von polygon oder so gehört - weiß jemand, wie das in diesem fall gehen soll?

SirThornberry 3. Mär 2006 14:17

Re: Quadrat 90° gedreht
 
willst du wirklich nur die Linie um 45° drehen oder doch das ganze bild?

wenn es nur um linie geht sollte die Funktion "PolyPolyline" eventuell das können was du willst.

[Edit]
Ich hab mich vertan, für deine Zwecke ist "Polyline" die richtige Funktion
Delphi-Quellcode:
var LPoints: Array of TPoint;
begin
  SetLength(LPoints, 5);
  LPoints[0] := Point(50, 0);
  LPoints[1] := Point(100, 50);
  LPoints[2] := Point(50, 100);
  LPoints[3] := Point(0, 50);
  LPoints[4] := Point(50, 0);
  Polyline(Image1.Picture.Bitmap.Canvas.Handle, Pointer(LPoints)^, Length(LPoints));
[/Edit]

netscanner 3. Mär 2006 14:26

Re: Quadrat 90° gedreht
 
die hab ich jetzt auch benutzt - danke an alle helfer
IHR seid SUPER - das muss man auch mal sagen ;)

SirThornberry 3. Mär 2006 14:39

Re: Quadrat 90° gedreht
 
Da ich in meiner Übereifrigkeit vorhin "PolyPolyline" angesprochen hab welches eigentlich zum zeichnen mehrere Polygone gedacht ist hier mal ein Beispiel für die Verwendung um 10 Polygone zu malen. (jeweils immer mit den 5 Punkten von Oben um 10 Pixel nach rechts verschoben)
Delphi-Quellcode:
var LPoints: Array of TPoint;
    LPolyCnts: Array of Integer;
    LCount,
    LPolyCnt: Integer;
begin
  LPolyCnt := 10;
  SetLength(LPoints, 5 * LPolyCnt);
  SetLength(LPolyCnts, LPolyCnt);
  for LCount := 0 to LPolyCnt - 1 do
  begin
    LPoints[0 + 5 * LCount] := Point(50 + LCount * 8, 0);
    LPoints[1 + 5 * LCount] := Point(100 + LCount * 8, 50);
    LPoints[2 + 5 * LCount] := Point(50 + LCount * 8, 100);
    LPoints[3 + 5 * LCount] := Point(0 + LCount * 8, 50);
    LPoints[4 + 5 * LCount] := Point(50 + LCount * 8, 0);
    LPolyCnts[LCount] := 5;
  end;
  PolyPolyline(Image1.Picture.Bitmap.Canvas.Handle, Pointer(LPoints)^, Pointer(LPolyCnts)^, LPolyCnt);


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz