Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Janilabo

ResizeBox

Recommended Posts

[scar]procedure ResizeBox(var bx: TBox; pixels, method: Integer);

begin

case method of

0: bx := Box((bx.X1 - pixels), (bx.Y1 - pixels), (bx.X2 + pixels), (bx.Y2 + pixels)); // WHOLE AREA (ALL AREAS BELOW)

1: bx := Box((bx.X1 - pixels), bx.Y1, (bx.X2 + pixels), bx.Y2); // WIDTH

2: bx := Box(bx.X1, (bx.Y1 - pixels), bx.X2, (bx.Y2 + pixels)); // HEIGHT

3: bx := Box(bx.X1, (bx.Y1 - pixels), bx.X2, bx.Y2); // UP

4: bx := Box(bx.X1, bx.Y1, bx.X2, (bx.Y2 + pixels)); // DOWN

5: bx := Box((bx.X1 - pixels), bx.Y1, bx.X2, bx.Y2); // LEFT

6: bx := Box(bx.X1, bx.Y1, (bx.X2 + pixels), bx.Y2); // RIGHT

7: bx := Box((bx.X1 - pixels), (bx.Y1 - pixels), bx.X2, bx.Y2); // TOP-LEFT

8: bx := Box(bx.X1, (bx.Y1 - pixels), (bx.X2 + pixels), bx.Y2); // TOP-RIGHT

9: bx := Box((bx.X1 - pixels), bx.X1, bx.X2, (bx.Y2 + pixels)); // BOTTOM-LEFT

10: bx := Box(bx.X1, bx.Y1, (bx.X2 + pixels), (bx.Y2 + pixels)); // BOTTOM-RIGHT

end;

end;

 

var

r_pixels: TIntArray;

h, i, m: Integer;

m_bx, r_bx: TBox;

 

begin

ClearDebug;

m_bx := Box(10, 10, 100, 100);

WriteLn('Original m_bx: ' + BoxToStr(m_bx) + #13#10);

r_pixels := [-1, 1, 5, 10];

h := High(r_pixels);

for i := 0 to h do

begin

for m := 0 to 10 do

begin

r_bx := m_bx;

ResizeBox(r_bx, r_pixels, m);

WriteLn('Resized m_bx: ' + BoxToStr(r_bx) + ' [' + 'Pixels: ' + IntToStr(r_pixels) + ', Method: ' + IntToStr(m) + ']');

end;

if (i < h) then

WriteLn('');

end;

end.[/scar]

Share this post


Link to post
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...