Author Topic: Is there a way to scale a window other than _FULLSCREEN?  (Read 6869 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline manstersoft

  • Newbie
  • Posts: 22
    • View Profile
    • My Games
Is there a way to scale a window other than _FULLSCREEN?
« on: August 10, 2020, 02:29:48 pm »
Say I'm making a program that has a resolution of 100x100 pixels. Is there a way I can scale the program to make it 200x200 and still keep its 100x100 resolution?
Same goes for Full Screen; can I scale the window to make the black frame wider/taller?

Offline +KZ

  • Newbie
  • Posts: 21
  • an ugly avatar :)
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #1 on: August 10, 2020, 05:13:46 pm »
i am using this on my program

http://www.qb64.org/wiki/NEWIMAGE

on PC-Basic i remember used SCREEN, WIDTH and HEIGHT


ignore this, I misunderstood you
« Last Edit: August 10, 2020, 05:15:51 pm by +KZ »
google translate :0

Offline +KZ

  • Newbie
  • Posts: 21
  • an ugly avatar :)
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #2 on: August 10, 2020, 09:41:15 pm »
although it occurs to me that you can multiply all graphic things by 2

example:

input pixelx
input pixely
 PSET pixelx x2, pixely x2
google translate :0

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #3 on: August 10, 2020, 10:12:47 pm »
http://www.qb64.org/wiki/$RESIZE Is the easiest way.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #4 on: August 10, 2020, 10:23:16 pm »
Here's a demo with Mousewheel!

Code: QB64: [Select]
  1. _TITLE "Expand and Contract Window, move mousewheel slowly..."
  2. SCREEN _NEWIMAGE(500, 500, 32)
  3. ' using const so the code can be more readable < great idea!
  4. CONST GOLD = &HFFFF9900, BLACK = &HFF000000, RED = &HFFFF0000, SQ = 50
  5.  
  6. n = 0
  7. LINE (46, 46)-STEP(400 + 4, 400 + 4), GOLD, BF
  8. FOR y = 1 TO 8
  9.     FOR x = 1 TO 8
  10.         n = (n + 1) MOD 2
  11.         IF n MOD 2 THEN colore& = RED ELSE colore& = BLACK
  12.         LINE (x * SQ, y * SQ)-STEP(SQ - 4, SQ - 4), colore&, BF
  13.     NEXT
  14.     n = (n + 1) MOD 2 '< for even amount of squares in a row
  15. img& = _NEWIMAGE(500, 500, 32)
  16. _PUTIMAGE , 0, img&
  17.         scroll = scroll + _MOUSEWHEEL
  18.         IF scroll < 200 AND scroll > -200 THEN
  19.             SCREEN _NEWIMAGE(500 + scroll, 500 + scroll, 32)
  20.             _PUTIMAGE , img&, 0
  21.         END IF
  22.     WEND
  23.     _DISPLAY
  24.     _LIMIT 10
  25.  
  26.  
  27.  
  28.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #5 on: August 11, 2020, 12:04:42 am »
You have a memory leak, bplus.  Don’t forgot to freeimage all those newimage screens.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #6 on: August 11, 2020, 01:24:21 am »
You have a memory leak, bplus.  Don’t forgot to freeimage all those newimage screens.

OK Memory Usage holding steady now:
Code: QB64: [Select]
  1. _TITLE "Expand and Contract Window, move mousewheel slowly..."
  2. SCREEN _NEWIMAGE(500, 500, 32)
  3. ' using const so the code can be more readable < great idea!
  4. CONST GOLD = &HFFFF9900, BLACK = &HFF000000, RED = &HFFFF0000, SQ = 50
  5. DIM tmp&(0 TO 10)
  6. n = 0
  7. LINE (46, 46)-STEP(400 + 4, 400 + 4), GOLD, BF
  8. FOR y = 1 TO 8
  9.     FOR x = 1 TO 8
  10.         n = (n + 1) MOD 2
  11.         IF n MOD 2 THEN colore& = RED ELSE colore& = BLACK
  12.         LINE (x * SQ, y * SQ)-STEP(SQ - 4, SQ - 4), colore&, BF
  13.     NEXT
  14.     n = (n + 1) MOD 2 '< for even amount of squares in a row
  15. img& = _NEWIMAGE(500, 500, 32)
  16. _PUTIMAGE , 0, img&
  17. lastt = 20
  18.         scroll = scroll + _MOUSEWHEEL
  19.     WEND
  20.     IF scroll < 200 AND scroll > -200 THEN
  21.         t = (t + 1) MOD 10
  22.         tmp&(t) = _NEWIMAGE(500 + scroll, 500 + scroll, 32)
  23.         SCREEN tmp&(t)
  24.         _PUTIMAGE , img&, 0
  25.     END IF
  26.  
  27.     PRINT lastt, t
  28.  
  29.     IF lastt <> 20 THEN _FREEIMAGE tmp&(lastt)
  30.     lastt = t
  31.     _DISPLAY
  32.     _LIMIT 10
  33.  
  34.  
  35.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #7 on: August 11, 2020, 08:36:50 am »
Hi
but this question
Quote
Say I'm making a program that has a resolution of 100x100 pixels. Is there a way I can scale the program to make it 200x200 and still keep its 100x100 resolution?
has behind (or covers) this one?
Quote
With scaling from 100x100 to 200x200 the objects(buttons, checkbox, sprite in movement are responsive to mouse's and keyboard's input...


We have our great IDE that suffers sometimes of interaction between menu and mouse when the dimensions of its window aren't the standard or it is in fullscreen!
So if this is a simple graphic output question, the answer solves the issue, otherwise if the questions is about the interaction between user's input by mouse and keyboard and the graphic interface I think that the solution can be reached following this idea but the coder must use a variable to check the position of mouse for interaction...

I can suggest another way... the use of WINDOW SCREEN (0,0)-(100,100) on the new window created.
As Bplus stressed in another thread you must manage by hand the interaction with _mouseX _mouseY

Good Luck in coding...
Programming isn't difficult, only it's  consuming time and coffee

Offline manstersoft

  • Newbie
  • Posts: 22
    • View Profile
    • My Games
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #8 on: August 11, 2020, 10:12:33 am »
although it occurs to me that you can multiply all graphic things by 2
Here's a demo with Mousewheel!
I can suggest another way... the use of WINDOW SCREEN (0,0)-(100,100) on the new window created.
I should have said, I work with text only. That checkers example is one smooooth program though.

http://www.qb64.org/wiki/$RESIZE Is the easiest way.
Thank you. I don't know how I had missed the RESIZE commands all these years.
This almost does the trick, but is it possible for me to set _SCREENWIDTH and _SCREENHEIGHT within the program?

It's not looking like there's a way to edit the scale in _FULLSCREEN either. Might have a couple of feature requests brewing.
« Last Edit: August 11, 2020, 10:21:54 am by manstersoft »

Marked as best answer by manstersoft on August 14, 2020, 11:40:10 am

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #9 on: August 11, 2020, 11:34:39 am »
SCREEN _NEWIMAGE(Width, Height, 0)
F = _LOADFONT(“cour.ttf”, 32, “monospace”)
_FONT F

The combination of the three commands above may be what you’re looking for.  Set the width and height of rows and columns with _NEWIMAGE, and choose your fontsize with _LOADFONT and _FONT.

A normal SCREEN 0 is 8 x 16 characters, with 80 columns and 25 rows, with a total size of 640x480 pixels.

If you want 80 columns and 25 rows of double sized characters, to increase scale for readability, _LOADFONT(desiredfont$, 32, “monospace”).

A 100x100 pixel-sized screen as you described, would be 12x6 columns and rows.  Simply loading a size 32 font of 1:2 ratio would be enough to scale the screen to 200x200 in size.

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #10 on: August 11, 2020, 01:20:56 pm »
TEXT ONLY!

Code: QB64: [Select]
  1. DEFINT A-Z
  2. _TITLE "ASCII Fireworks,    Move Mousewheel to Expand or Contract" '2020-01-01
  3. ' 2020-01-02 update with graivity effect by tsh73 from JB forum
  4. ' 2020-08-11 modified for xpanding and contracting screen size
  5.  
  6. CONST nR = 5, t = "     Happy New Year QB64 Forum, ASCII Fireworks Brought To You By Bplus Inspired by Pete, TempodiBasic and [banned user] Recent Efforts, Gravity Effect by tsh73 at JB Forum, Go In Peace 2020!....."
  7. TYPE rocket
  8.     x AS SINGLE
  9.     y AS SINGLE
  10.     bang AS INTEGER
  11.     age AS INTEGER
  12.     c AS INTEGER
  13. qb(0) = &HFF000000
  14. qb(1) = &HFF000088
  15. qb(2) = &HFF008800
  16. qb(3) = &HFF008888
  17. qb(4) = &HFF880000
  18. qb(5) = &HFF880088
  19. qb(6) = &HFF888800
  20. qb(7) = &HFFCCCCCC
  21. qb(8) = &HFF888888
  22. qb(9) = &HFF0000FF
  23. qb(10) = &HFF00FF00
  24. qb(11) = &HFF00FFFF
  25. qb(12) = &HFFFF0000
  26. qb(13) = &HFFFF00FF
  27. qb(14) = &HFFFFFF00
  28. qb(15) = &HFFFFFFFF
  29.  
  30. DIM SHARED r(1 TO nR) AS rocket
  31. FOR i = 1 TO nR
  32.     new i
  33. DIM SHARED fire&
  34. fire& = _NEWIMAGE(640, 400, 32)
  35. DIM tmp&(0 TO 10)
  36. lastt = 20
  37. sc& = _NEWIMAGE(640, 400, 32)
  38.  
  39.     _DEST fire&
  40.     CLS
  41.     COLOR qb(13)
  42.     lc = lc + 1
  43.     IF lc MOD 3 = 0 THEN p = (p + 1) MOD LEN(t)
  44.     LOCATE 2, 20: PRINT MID$(t, p + 1, 40);
  45.     rocs = rocs + 1
  46.     IF rocs > nR THEN rocs = nR
  47.     FOR i = 1 TO rocs
  48.         drawRocket i
  49.     NEXT
  50.  
  51.  
  52.     _DEST 0
  53.         scroll = scroll + _MOUSEWHEEL
  54.     WEND
  55.     IF scroll < 800 AND scroll > -400 THEN
  56.         tp = (tp + 1) MOD 10
  57.         tmp&(tp) = _NEWIMAGE(640 + scroll, 400 + scroll, 32)
  58.         SCREEN tmp&(tp)
  59.         _PUTIMAGE , fire&, 0
  60.     ELSE
  61.         lastt = 20
  62.     END IF
  63.  
  64.     'debug
  65.     'COLOR qb(15)
  66.     'LOCATE 1, 1: PRINT lastt, tp, scroll
  67.  
  68.     IF lastt <> 20 THEN _FREEIMAGE tmp&(lastt)
  69.     lastt = tp
  70.  
  71.     _DISPLAY
  72.     _LIMIT 20
  73.  
  74. SUB new (i)
  75.     r(i).x = RND * 60 + 10
  76.     r(i).y = 25
  77.     r(i).bang = RND * 20
  78.     r(i).age = 0
  79.     r(i).c = INT(RND * 15) + 1
  80.  
  81. SUB drawRocket (i)
  82.     IF r(i).y > r(i).bang THEN
  83.         COLOR qb(15)
  84.         LOCATE r(i).y, r(i).x: PRINT CHR$(24);
  85.         r(i).y = r(i).y - 1
  86.     ELSE
  87.         r(i).age = r(i).age + 1
  88.         IF r(i).age > 25 THEN
  89.             new i
  90.         ELSE
  91.             COLOR qb(r(i).c)
  92.             IF r(i).age > 4 THEN start = r(i).age - 4 ELSE start = 1
  93.             FOR a = start TO r(i).age
  94.                 FOR j = 1 TO 12
  95.                     xx = r(i).x + 1 * a * COS(j * _PI / 6)
  96.                     yy = r(i).y + .5 * a * SIN(j * _PI / 6)
  97.                     yy = yy + (r(i).y - a) ^ 2 / 15 '<<<< tsh73 gravity
  98.                     IF xx > 0 AND xx < 81 AND yy > 0 AND yy < 26 THEN
  99.                         LOCATE INT(yy), INT(xx)
  100.                         PRINT "*";
  101.                     END IF
  102.                 NEXT
  103.             NEXT
  104.         END IF
  105.     END IF
  106.  
  107.  
  108.  
  109.  
 [ You are not allowed to view this attachment ]  

  [ You are not allowed to view this attachment ]  
« Last Edit: August 11, 2020, 01:24:51 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #11 on: August 11, 2020, 07:32:50 pm »
I should have said, I work with text only. That checkers example is one smooooth program though.
Yes I agree, however this is your window on which you're working!
Code: QB64: [Select]
  1. k = 100
  2. s$ = "a"
  3.     IF s$ <> "" THEN
  4.         w = k / 8
  5.         h = k / 16
  6.         SCREEN _NEWIMAGE(w, h, 0)
  7.         'WINDOW SCREEN(1, 1)-(100, 100) '<-- this activates an error of illegal function
  8.         LOCATE 1, 1
  9.         FOR a = 1 TO w
  10.             PRINT LTRIM$(STR$(a MOD 10));
  11.             _DELAY .1
  12.         NEXT a
  13.         LOCATE 2
  14.         FOR a = 2 TO h
  15.             LOCATE a, 1
  16.             PRINT LTRIM$(STR$(a MOD 10));
  17.             LOCATE a, w
  18.             PRINT LTRIM$(STR$(a MOD 10));
  19.             _DELAY .1
  20.         NEXT a
  21.         LOCATE 3, 3: PRINT w;
  22.         LOCATE 4, 4: PRINT h;
  23.     END IF
  24.     s$ = INKEY$
  25.     IF s$ = CHR$(32) THEN IF k > 100 THEN k = 100 ELSE k = k + 100
  26. LOOP UNTIL s$ = CHR$(27)

Why do you talk about pixels when you work in Screen 0 (console mode)? It is preferable to talk in row and column dimensions...
It is clear that here we NEED the opinion of the King of ASCII screen mode!
I'll invite Pete to talk about this issue.

PS:
Bplus I find great your fireworks!
Programming isn't difficult, only it's  consuming time and coffee

Offline manstersoft

  • Newbie
  • Posts: 22
    • View Profile
    • My Games
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #12 on: August 12, 2020, 08:42:32 pm »
Why do you talk about pixels when you work in Screen 0 (console mode)? It is preferable to talk in row and column dimensions...
Excuse my terminology screw up. Since I switched to QB64 I'm actually using...
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(scale * 8, scale * 8, 256): _FONT 8
I can't stand using only 8 background colors.

The SCREEN() function is a major reason I've stuck with Quick Basic; many other variants don't have anything like this function. My main worry with rendering text as graphics is that I won't be able to use the SCREEN() function.
Side note: SCREEN() does have an issue where it confuses a non-COLOR ,0 " " for a block when using SCREEN _NEWIMAGE.

I haven't had time today to look at the code y'all posted though (I'm selling my house/land; anyone in Central Virginia want to buy it?), so there might be some answers in there. I want to mess with that ASCII fireworks program anyway.

And thanks for all of the replies.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #13 on: August 12, 2020, 08:59:10 pm »
_FONT 8 for fireworks, great idea! A number of changes (and the program is less lines!):
Code: QB64: [Select]
  1. DEFINT A-Z
  2. _TITLE "ASCII Fireworks  Move Mousewheel to Expand or Contract #2" '2020-01-01
  3. ' 2020-01-02 update with graivity effect by tsh73 from JB forum
  4. ' 2020-08-11 modified for xpanding and contracting screen size
  5. ' 2020-08-11 Steve catches memory leak, fixed!
  6. ' 2020-08-12 manstersoft gives me idea for Font 8, added more works and switched color to more! RGB32
  7.  
  8. CONST nR = 9, t = "     Happy New Year QB64 Forum, ASCII Fireworks Brought To You By Bplus Inspired by Pete, TempodiBasic and [banned user] Recent Efforts, Gravity Effect by tsh73 at JB Forum, Thanks Steve for saving memory and manstersoft for Font 8 idea, Go In Peace 2020!....."
  9. TYPE rocket
  10.     x AS SINGLE
  11.     y AS SINGLE
  12.     bang AS INTEGER
  13.     age AS INTEGER
  14.     c AS _UNSIGNED LONG
  15.  
  16. DIM SHARED r(1 TO nR) AS rocket
  17. FOR i = 1 TO nR
  18.     new i
  19. DIM SHARED fire&
  20. fire& = _NEWIMAGE(640, 400, 32)
  21. DIM tmp&(0 TO 10)
  22. lastt = 20
  23. sc& = _NEWIMAGE(640, 400, 32)
  24.     _DEST fire&
  25.     _FONT 16
  26.     CLS
  27.     COLOR &HFFFF88AA
  28.     lc = lc + 1
  29.     IF lc MOD 3 = 0 THEN p = (p + 1) MOD LEN(t)
  30.     LOCATE 2, 20: PRINT MID$(t, p + 1, 40);
  31.     _FONT 8
  32.     rocs = rocs + 1
  33.     IF rocs > nR THEN rocs = nR
  34.     FOR i = 1 TO rocs
  35.         drawRocket i
  36.     NEXT
  37.  
  38.  
  39.     _DEST 0
  40.         scroll = scroll + _MOUSEWHEEL
  41.     WEND
  42.     IF scroll < 800 AND scroll > -400 THEN
  43.         tp = (tp + 1) MOD 10
  44.         tmp&(tp) = _NEWIMAGE(640 + scroll, 400 + scroll, 32)
  45.         SCREEN tmp&(tp)
  46.         _PUTIMAGE , fire&, 0
  47.     ELSE
  48.         lastt = 20
  49.     END IF
  50.  
  51.     'debug
  52.     'COLOR qb(15)
  53.     'LOCATE 1, 1: PRINT lastt, tp, scroll
  54.  
  55.     IF lastt <> 20 THEN _FREEIMAGE tmp&(lastt)
  56.     lastt = tp
  57.  
  58.     _DISPLAY
  59.     _LIMIT 20
  60.  
  61. SUB new (i)
  62.     r(i).x = RND * 60 + 10
  63.     r(i).y = 50
  64.     r(i).bang = RND * 30
  65.     r(i).age = 0
  66.     r(i).c = _RGB32(200 * RND + 55, 200 * RND + 55, 200 * RND + 55)
  67.  
  68. SUB drawRocket (i)
  69.     IF r(i).y > r(i).bang THEN
  70.         COLOR r(i).c
  71.         LOCATE r(i).y, r(i).x: PRINT CHR$(24);
  72.         r(i).y = r(i).y - 1
  73.     ELSE
  74.         r(i).age = r(i).age + 1
  75.         IF r(i).age > 50 THEN
  76.             new i
  77.         ELSE
  78.             COLOR r(i).c
  79.             IF r(i).age > 4 THEN start = r(i).age - 4 ELSE start = 1
  80.             FOR a = start TO r(i).age
  81.                 FOR j = 1 TO 12
  82.                     xx = r(i).x + 1 * a * COS(j * _PI / 6)
  83.                     yy = r(i).y + .5 * a * SIN(j * _PI / 6)
  84.                     yy = yy + (r(i).y - a) ^ 2 / 15 '<<<< tsh73 gravity
  85.                     IF xx > 0 AND xx < 81 AND yy > 0 AND yy < 51 THEN
  86.                         LOCATE INT(yy), INT(xx)
  87.                         PRINT "*";
  88.                     END IF
  89.                 NEXT
  90.             NEXT
  91.         END IF
  92.     END IF
  93.  
  94.  
« Last Edit: August 12, 2020, 09:29:30 pm by bplus »

Offline manstersoft

  • Newbie
  • Posts: 22
    • View Profile
    • My Games
Re: Is there a way to scale a window other than _FULLSCREEN?
« Reply #14 on: August 13, 2020, 12:03:12 am »
_FONT 8 for fireworks, great idea! A number of changes (and the program is less lines!):
Wow, what a program. I'll have to post a gif of that on Twitter. There are a lot of ASCII nuts on there.
And thanks for the shout-out. _FONT 8 was a game-changer for me.

Sheesh, I've still got so much to learn. I can't make heads or tails of that code.
If I ever posted any of my programs on here I'm sure SMcNeill would find 200 memory leaks.
Speaking of which, I gotta try out that code he posted.

Edit: Tried it out. The Screen function isn't compatible with it (it even throws up an error).
« Last Edit: August 13, 2020, 12:22:06 am by manstersoft »