07-24-2022, 08:28 PM
As I posted in a different thread in the Help area, I thought I'd go ahead and share these two demos here to help preserve them for the future.
Demo 1 here is an example of how to use $RESIZE:ON to adjust your program's width and height, without adjusting the fontsize or scale. This works basically like the IDE does, and resizes the number of rows and columns which you have available for use with the program:
Demo 2 here works in a very similar manner, except it uses two screens. The activeScreen always remains the same size -- 640 x 400 pixels, in this case, and the viewScreen changes size and scales the image on the screen to suit whatever size we expand it to:
Note that neither of these demos maintain aspect ratio, so images may stretch or skew depending on how you resize them. If this isn't your desired effect, then you'd have to adjust for that inside the program with a few IF statements manually.
Demo 1 here is an example of how to use $RESIZE:ON to adjust your program's width and height, without adjusting the fontsize or scale. This works basically like the IDE does, and resizes the number of rows and columns which you have available for use with the program:
Code: (Select All)
$Resize:On
activeScreen = _NewImage(80, 25, 0) 'standard screen 0
Screen activeScreen
DrawBorder
_Delay .25
clearInitialResize = _Resize 'clear thr size change from where QB64 first starts up
Do
If _Resize Then
tempScreen = _NewImage(_ResizeWidth \ _FontWidth, _ResizeHeight \ _FontHeight, 0)
Screen tempScreen
_FreeImage activeScreen
activeScreen = tempScreen
DrawBorder
End If
Loop Until _KeyHit
System
Sub DrawBorder
Color 4
For x = 1 To _Width
Locate 1, x: Print Chr$(219);
Locate _Height, x: Print Chr$(219);
Next
For y = 1 To _Height
Locate y, 1: Print Chr$(219);
Locate y, _Width: Print Chr$(219);
Next
Color 15
Locate _Height \ 2, _Width \ 2 - 12: Print "Resize On, Non-Scale Demo"
Locate _Height \ 2 + 2, 3: Print "Width:"; _Width
Locate _Height \ 2 + 3, 3: Print "Height:"; _Height
End Sub
Demo 2 here works in a very similar manner, except it uses two screens. The activeScreen always remains the same size -- 640 x 400 pixels, in this case, and the viewScreen changes size and scales the image on the screen to suit whatever size we expand it to:
Code: (Select All)
$Resize:On
activeScreen = _NewImage(640, 400, 256) '256 color screen so we can use _PUTIMAGE for scaling
viewScreen = _NewImage(640, 400, 256) 'a second screen to scale to
Screen viewScreen
_Dest activeScreen: _Source activeScreen
DrawBorder
_Delay .25
clearInitialResize = _Resize 'clear thr size change from where QB64 first starts up
Do
If _Resize Then
tempScreen = _NewImage(_ResizeWidth, _ResizeHeight, 256)
Screen tempScreen
_FreeImage viewScreen
viewScreen = tempScreen
End If
_PutImage , activeScreen, viewScreen
_Limit 30
Loop Until _KeyHit
System
Sub DrawBorder
Color 4
For x = 1 To _Width \ _FontWidth
Locate 1, x: Print Chr$(219);
Locate _Height \ _FontHeight, x: Print Chr$(219);
Next
For y = 1 To _Height \ _FontHeight
Locate y, 1: Print Chr$(219);
Locate y, _Width \ _FontWidth: Print Chr$(219);
Next
Color 15
Locate 3, 3: Print "Resize On, Scale-Size Demo"
Locate 5, 3: Print "Width:"; _Width
Locate 6, 3: Print "Height:"; _Height
End Sub
Note that neither of these demos maintain aspect ratio, so images may stretch or skew depending on how you resize them. If this isn't your desired effect, then you'd have to adjust for that inside the program with a few IF statements manually.