Difference between revisions of "RESIZE (function)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
m (Nomalise Availability section text)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:_RESIZE (function)}}
{{DISPLAYTITLE:_RESIZE (function)}}
The '''_RESIZE''' function returns -1 when a user has attempted to resize the program window and [[$RESIZE]]:ON has allowed it.
The [[_RESIZE]] function returns true (-1) when a user has attempted to resize the program window and [[$RESIZE]]:ON has allowed it.




{{PageSyntax}}
{{PageSyntax}}
::: IF '''_RESIZE''' THEN rx& = [[_RESIZEWIDTH]]: ry& = [[_RESIZEHEIGHT]]
: IF '''_RESIZE''' THEN rx& = [[_RESIZEWIDTH]]: ry& = [[_RESIZEHEIGHT]]




''Details:''
{{PageDescription}}
* The function returns -1 if a resize was attempted by the user.  
* The function returns -1 if a program screen resize was attempted by the user.  
* After the function returns -1, [[_RESIZEWIDTH]] and [[_RESIZEHEIGHT]] can return the new dimensions in pixels.
* After the function returns -1, [[_RESIZEWIDTH]] and [[_RESIZEHEIGHT]] can return the new requested dimensions in pixels.
* The [[$RESIZE]]:ON [[metacommand]] must be used so the program is created with a user resizable window.
* The [[$RESIZE]]:ON [[metacommand]] must be used so the program is created with a user resizable window.




''See also:''
{{PageAvailability}}
* Version 1.000 and up.
 
 
{{PageExamples}}
''Example:'' Resize the current screen image according to user's request.
{{CodeStart}}
{{Cl|$RESIZE}}:ON
 
s& = {{Cl|_NEWIMAGE}}(300, 300, 32)
{{Cl|SCREEN}} s&
 
bee& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'replace with your own image
 
{{Cl|DO}}
    {{Cl|IF}} {{Cl|_RESIZE (function)|_RESIZE}} THEN
        oldimage& = s&
        s& = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32)
        SCREEN s&
        {{Cl|_FREEIMAGE}} oldimage&
    END IF
 
    {{Cl|CLS}}
 
    'Center the image:
    x = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - _WIDTH(bee&) / 2
    y = {{Cl|_HEIGHT}} / 2 - _HEIGHT(bee&) / 2
    {{Cl|_PUTIMAGE}} (x, y), bee&
    {{Cl|_DISPLAY}}
    {{Cl|_LIMIT}} 30
{{Cl|LOOP}}
{{CodeEnd}}
 
 
{{PageSeeAlso}}
* [[$RESIZE]] {{text|(metacommand)}}
* [[$RESIZE]] {{text|(metacommand)}}
* [[_RESIZE]]
* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(requested pixel dimensions)}}
* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(requested pixel dimensions)}}




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 03:19, 8 March 2021

The _RESIZE function returns true (-1) when a user has attempted to resize the program window and $RESIZE:ON has allowed it.


Syntax

IF _RESIZE THEN rx& = _RESIZEWIDTH: ry& = _RESIZEHEIGHT


Description

  • The function returns -1 if a program screen resize was attempted by the user.
  • After the function returns -1, _RESIZEWIDTH and _RESIZEHEIGHT can return the new requested dimensions in pixels.
  • The $RESIZE:ON metacommand must be used so the program is created with a user resizable window.


Availability

  • Version 1.000 and up.


Examples

Example: Resize the current screen image according to user's request.

$RESIZE:ON s& = _NEWIMAGE(300, 300, 32) SCREEN s& bee& = _LOADIMAGE("qb64_trans.png") 'replace with your own image DO IF _RESIZE THEN oldimage& = s& s& = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32) SCREEN s& _FREEIMAGE oldimage& END IF CLS 'Center the image: x = _WIDTH / 2 - _WIDTH(bee&) / 2 y = _HEIGHT / 2 - _HEIGHT(bee&) / 2 _PUTIMAGE (x, y), bee& _DISPLAY _LIMIT 30 LOOP


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page