Jump to content
Janilabo

TPARow & TPAColumn

Recommended Posts

Made these 2 useful little commands.

Play around with the constants, to see how these work.. ;)

Constants can be negative aswell. Well, only TEST_SIZE has to be higher than 0 for these to work.

 

const
 TEST_START_X = 0;
 TEST_START_Y = 0;
 TEST_SIZE = 10;
 TEST_SPACE = 1;

function TPARow(rowStart: TPoint; rowSize, rowSpace: Integer): TPointArray;
var
 i: Integer;
begin
 if (rowSize > 0) then
 begin
   SetLength(Result, rowSize);
   for i := 0 to (rowSize - 1) do
   begin
     Result[i].X := rowStart.X;
     Result[i].Y := (rowStart.Y + (i * rowSpace));
   end; 
 end;
end;

function TPAColumn(columnStart: TPoint; columnSize, columnSpace: Integer): TPointArray;
var
 i: Integer;
begin
 if (columnSize > 0) then
 begin
   SetLength(Result, columnSize);
   for i := 0 to (columnSize - 1) do
   begin                         
     Result[i].X := (columnStart.X + (i * columnSpace));
     Result[i].Y := columnStart.Y;                       
   end; 
 end;
end;

var
 startPt: TPoint;
 TPA: TPointArray;

begin
 startPt := Point(TEST_START_X, TEST_START_Y);          
 TPA := TPARow(startPt, TEST_SIZE, TEST_SPACE);
 WriteLn('TPARow(' + PointToStr(startPt) + ', ' + IntToStr(TEST_SIZE) + ', ' + IntToStr(TEST_SPACE) + '): ' + #13#10 + TPAToStr(TPA));
 SetLength(TPA, 0);
 WriteLn('');
 TPA := TPAColumn(startPt, TEST_SIZE, TEST_SPACE);
 WriteLn('TPAColumn(' + PointToStr(startPt) + ', ' + IntToStr(TEST_SIZE) + ', ' + IntToStr(TEST_SPACE) + '): ' + #13#10 + TPAToStr(TPA));
 SetLength(TPA, 0);
end.

 

Anyone have any better name suggestions for em? :)

 

Also, TPAGrid():

 

const
 GRID_START_X = 0;
 GRID_START_Y = 0;
 GRID_ROWS = 3;     
 GRID_COLUMNS = 3;
 GRID_ROW_SPACE = 1;
 GRID_COLUMN_SPACE = 1;

function TPAGrid(start: TPoint; rows, columns, rowSpace, columnSpace: Integer): TPointArray;
var
 i, s, r, c: Integer;
begin
 if ((rows < 0) or (columns < 0)) then
   Exit;
 s := (rows * columns);
 if (s > 0) then
 begin
   SetLength(Result, s);
   for r := 0 to (rows - 1) do
     for c := 0 to (columns - 1) do
     begin    
       i := ((r * columns) + c);                    
       Result[i].X := (start.X + (c * columnSpace));
       Result[i].Y := (start.Y + (r * rowSpace));
     end;
 end;
end;

var
 TPA: TPointArray;

begin
 ClearDebug;
 TPA := TPAGrid(Point(GRID_START_X, GRID_START_Y), GRID_ROWS, GRID_COLUMNS, GRID_ROW_SPACE, GRID_COLUMN_SPACE);
 WriteLn('TPAGrid((' + IntToStr(GRID_START_X) + ',' + IntToStr(GRID_START_Y) + '), ' + IntToStr(GRID_ROWS) + ', ' + IntToStr(GRID_COLUMNS) + ', ' + IntToStr(GRID_ROW_SPACE) + ', ' + IntToStr(GRID_COLUMN_SPACE) + '):');
 WriteLn(TPAToStr(TPA));
 SetLength(TPA, 0);
end.

 

..aaaaand TBAGrid():

 

function TBAGrid(start: TPoint; boxWidth, boxHeight, rows, columns, rowSpace, columnSpace: Integer): TBoxArray;
var
 i, s, r, c: Integer;
begin
 if ((rows < 0) or (columns < 0) or (boxWidth < 1) or (boxHeight < 1)) then
   Exit;
 s := (rows * columns);
 if (s > 0) then
 begin
   SetLength(Result, s);
   for r := 0 to (rows - 1) do
     for c := 0 to (columns - 1) do
     begin    
       i := ((r * columns) + c);                    
       Result[i].X1 := (start.X + (c * columnSpace));
       Result[i].Y1 := (start.Y + (r * rowSpace)); 
       Result[i].X2 := (Result[i].X1 + (boxWidth - 1));
       Result[i].Y2 := (Result[i].Y1 + (boxHeight - 1));
     end;
 end;
end;

 

TBARow() & TBAColumn():

 

function TBARow(start: TPoint; boxWidth, boxHeight, rowSize, rowSpace: Integer): TBoxArray;
var
 i: Integer;
begin
 if ((rowSize > 0) and (boxWidth > 0) and (boxHeight > 0)) then
 begin           
   SetLength(Result, rowSize);
   for i := 0 to (rowSize - 1) do
   begin                     
     Result[i].X1 := start.X;
     Result[i].Y1 := (start.Y + (i * rowSpace)); 
     Result[i].X2 := (Result[i].X1 + (boxWidth - 1));
     Result[i].Y2 := (Result[i].Y1 + (boxHeight - 1));
   end;
 end;
end;

function TBAColumn(start: TPoint; boxWidth, boxHeight, columnSize, columnSpace: Integer): TBoxArray;
var
 i: Integer;
begin
 if ((columnSize > 0) and (boxWidth > 0) and (boxHeight > 0)) then
 begin           
   SetLength(Result, columnSize);
   for i := 0 to (columnSize - 1) do
   begin                     
     Result[i].X1 := (start.X + (i * columnSpace));
     Result[i].Y1 := start.Y; 
     Result[i].X2 := (Result[i].X1 + (boxWidth - 1));
     Result[i].Y2 := (Result[i].Y1 + (boxHeight - 1));
   end;
 end;
end;

 

http://uppit.com/1azcxakq7tuc/Grid_stuff.zip (some examples for most of these functions)

 

-Jani

Edited by Janilabo
Added TBAColumn / TBARow and corrected TPAGrid/TBAGrid.
Link to comment
Share on other sites

オンライン カジノは、プレイヤーが自宅にいながらにしてポーカー、ルーレット、ブラックジャック、スロットなどのギャンブル ゲームを楽しむ機会を提供する仮想プラットフォームです。 オンラインカジノは、アクセスのしやすさ、ゲームの種類の多さ、そして大金を獲得する機会があるため、年々人気が高まっています。

オンラインカジノの主な利点は、利便性とアクセスしやすさです。 プレイヤーは、通常のカジノの営業時間に制限されず、いつでもゲームを楽しむことができます。 必要なのは、インターネットにアクセスできるデバイスと、カジノのウェブサイトにアクセスできることだけです。 これにより、プレイヤーは従来のカジノによくありがちなストレスや緊張を感じることなく、快適な環境でプレイすることができます。

オンラインカジノのもう1つの利点は、ゲームの選択肢が豊富なことです。 ユーザーは、それぞれ独自のルールと勝利の機会を提供する何百もの異なるゲームから選択できます。 技術革新のおかげで、オンライン ゲームのグラフィックとサウンドは高品質になり、プレイヤーは興奮と情熱の雰囲気に浸ることができます。

さまざまなゲームに加えて、オンライン カジノはプレーヤーにさまざまなボーナスやプロモーションも提供します。 これらは、スロットのフリースピン、プレイのための追加のお金、または貴重な賞品が得られる特別なトーナメントなどです。 このようなボーナスにより、勝利の可能性が高まり、ゲームがさらに楽しくなります。

もちろん、オンラインカジノでのプレイにはリスクがあります。 ギャンブルには依存性がある可能性があるため、自分の感情を監視し、支出をコントロールすることが重要であることを覚えておくことが重要です。 カジノはまた、責任あるゲーミングをサポートし、自己排除や賭け金制限の機会を提供します オンライン カジノ

全体として、オンライン カジノはギャンブル愛好家にとって便利でエキサイティングなエンターテイメントを提供します。 幅広いゲーム、ボーナスの選択肢があり、いつでもプレイできるため、世界中のプレイヤーの間で人気が高まっています。 ただし、責任あるゲームと、ゲームが単なる楽しみと娯楽の源であるように自分の行動を制御する能力について覚えておくことが重要です。
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...