Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi canvas.TextOut Eingabe spiegeln ? (https://www.delphipraxis.net/144785-canvas-textout-eingabe-spiegeln.html)

onkeldave 16. Dez 2009 17:51


canvas.TextOut Eingabe spiegeln ?
 
[b]Wir sollen für die schule ein Projekt bzw. eher ein Programm schreiben

wir sollen '*' ausgeben in Muster Form

Als Erste gebe ich ein T aus, so ganz einfach
http://i45.tinypic.com/v5vmvb.jpg
Hier der Programierungs abschnit
Zitat:

procedure TForm1.grosst(anzahl:Integer);
var x, y : integer;
begin
For x := 1 to anzahl+anzahl do Begin // Der Seitliche Strich
for y:= 1 to 2 do begin // Die Breite
canvas.textout(x*groesse,y*groesse,'*');
// Abstand der sternchen an groeese angebpasst
end;

end;
For x:= anzahl to anzahl+1 do Begin // Breite
For y:= 1 to anzahl+anzahl do Begin // Strich nach unten
canvas.TextOut(x*groesse, y*groesse,'*');
end;
end;
end;
Kein Problem ^^

ABER JETZT

http://i50.tinypic.com/2zq7g54.jpg

Ich will jetzt das Selbe nur gespiegelt halt das ein umgedrehtes V raus kommt
hier nochmal der programierungs Abschnitt
Zitat:

procedure TForm1.kleint(anzahl:Integer);
var x, y : integer ;
begin
For x:= anzahl to anzahl+anzahl do Begin
For y:= 1 to anzahl+anzahl do Begin
canvas.TextOut(x*groesse,x*groesse,'*');
end;
end;

(*For x:= anzahl to anzahl+anzahl do Begin
For y:= 1 to anzahl+anzahl do Begin
canvas.TextOut(x*groesse,x*groesse,'*');
end;
end; *) // Das selbe spiegeln ?!?!?!



Hier noch meine Unit
Zitat:

unit stern_u;

interface

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

type
TForm1 = class(TForm)
Panel1: TPanel;
ed_eingabe: TEdit;
btn_ok: TButton;
Button1: TButton;
Rg_auswahl: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure btn_okClick(Sender: TObject);
private
procedure grosst(anzahl:integer);
procedure kleint(anzahl:Integer);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
const
groesse = 30;
var
Form1: TForm1;

implementation

{$R *.dfm}
//------------------großes T--------------------------------------
procedure TForm1.grosst(anzahl:Integer);
var x, y : integer;
begin
For x := 1 to anzahl+anzahl do Begin // Der Seitliche Strich
for y:= 1 to 2 do begin // Die Breite
canvas.textout(x*groesse,y*groesse,'*');
// Abstand der sternchen an groeese angebpasst
end;

end;
For x:= anzahl to anzahl+1 do Begin // Breite
For y:= 1 to anzahl+anzahl do Begin // Strich nach unten
canvas.TextOut(x*groesse, y*groesse,'*');
end;
end;
end;
//-------------------großes Ende----------------------------------

//-------------------umgedrehtes V------------------------------------
procedure TForm1.kleint(anzahl:Integer);
var x, y : integer ;
begin
For x:= anzahl to anzahl+anzahl do Begin
For y:= 1 to anzahl+anzahl do Begin
canvas.TextOut(x*groesse,x*groesse,'*');
end;
end;

(*For x:= anzahl to anzahl+anzahl do Begin
For y:= 1 to anzahl+anzahl do Begin
canvas.TextOut(x*groesse,x*groesse,'*');
end;
end; *) // Das selbe spiegeln ?!?!?!
end;
//-------------------umgedrehtes V Ende--------------------------------

procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Repaint
end;

procedure TForm1.btn_okClick(Sender: TObject);
var
anzahl: Integer;
begin
anzahl:= strtoint (ed_eingabe.text);
canvas.font.height:= groesse;
canvas.font.color:= clgreen;
if anzahl<4 then begin
ShowMessage ('Diese Zahl ist LEIDER zu klein');
ed_eingabe.text:= IntToStr(4);
Anzahl:= 4;
end;
If anzahl > 12 then begin
ShowMessage ('das geht nicht');
ed_eingabe.text:=IntToStr(12);
anzahl:= 12;
end;
case rg_auswahl.itemindex of
0 : grosst(anzahl);
1 : kleint(anzahl);

end;
end;
end.

ach ja von dem canvas verstehe ich noch nicht so viel ^^ haben wir jetzt erst 1 Stunde gehabt

DANK SCHONMAL FÜR EURE HILFE

onkeldave 17. Dez 2009 18:06

Re: canvas.TextOut Eingabe spiegeln ?
 
kann mir keiner helfen ?
:gruebel:
:?:

onkeldave 22. Dez 2009 13:37

Re: canvas.TextOut Eingabe spiegeln ?
 
hat keiner eine Idee oder so

ich will ja nur wissen wie man nun die sterne spiegelt damit ein umgedrehtes V rauskommt ......

:| :?: :?:

franktron 22. Dez 2009 13:58

Re: canvas.TextOut Eingabe spiegeln ?
 
Las die Schleifen andersherum laufen

also nicht 1 To x
sonder x Downto 1


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:01 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 by Thomas Breitkreuz