Author Topic: Sizing screen for graphics  (Read 3348 times)

0 Members and 1 Guest are viewing this topic.

Offline AuleMar

  • Newbie
  • Posts: 3
    • View Profile
Sizing screen for graphics
« on: August 03, 2020, 02:36:01 pm »
New user to QB64, I searched the forum but haven't found What I'm looking for.  I did find how to change screen size for text and that has worked.  But, when a graphic object is drawn the screen (window) snaps back to the original tiny size.  What I am doing Is simple graphics, Just a line drawings of an objects finite element grid.  I use it to verify the grid prior to using it in a FORTRAN code. Is there a way to size the screen for graphics. 
PS; New user but retired engineer, trying to teach the grand-kids real world problems using there 64 bit gaming computers.
Thanks..

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sizing screen for graphics
« Reply #1 on: August 03, 2020, 02:44:33 pm »
Welcome AuleMar!

Many screen modes but this is modern way to start:

Code: QB64: [Select]
  1. pixelWidth = 800: pixelHeight = 600 'std screen size
  2. SCREEN _NEWIMAGE(pixelWidth, pixelHeight, 32) ' << 32 indicates the _RGB32(red, green, blue) colors mode

A simple little graphic that might serve as example:
Code: QB64: [Select]
  1. _TITLE "TV Static test, press esc to quit!"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4. WHILE 1 'to make static move around put it in endless loop
  5.     'cheap way to draw box
  6.     FOR w = 50 TO 1 STEP -.25
  7.         LINE (100 - w, 100 - w)-(700 - 2 * w, 550 - 2 * w), _RGB32(124 - w, 62 - .5 * w, 31 - .25 * w), B
  8.     NEXT
  9.     LINE (100, 100)-(700, 550), _RGB32(124, 62, 31), BF
  10.  
  11.     'some knobs
  12.     FOR r = 20 TO 1 STEP -.5
  13.         CIRCLE (200, 500), r, _RGB(255 - r * 12, 255 - r * 12, 255 - r * 12)
  14.         CIRCLE (600, 500), r, _RGB(255 - r * 12, 255 - r * 12, 255 - r * 12)
  15.     NEXT
  16.     FOR r = 4 TO 1 STEP -.1
  17.         CIRCLE (200 + r, 500 + r), 8 - .5 * r, _RGB(0, 0, 0)
  18.         CIRCLE (600 + r, 500 + r), 8 - .5 * r, _RGB(0, 0, 0)
  19.         CIRCLE (300 + r, 500 + r), 8 - .5 * r, _RGB(0, 0, 0)
  20.         CIRCLE (400 + r, 500 + r), 8 - .5 * r, _RGB(0, 0, 0)
  21.         CIRCLE (500 + r, 500 + r), 8 - .5 * r, _RGB(0, 0, 0)
  22.     NEXT
  23.     'picture "tube"
  24.     FOR y = 150 TO 450 '                                           y range of box
  25.         FOR x = 150 TO 650 '                                       x range of box
  26.             '   _RGB32(red, green, blue) sets color in this graphics screen mode
  27.             'B&W static   make R, G, B all same number for a shade of gray
  28.             rNumber = RND * 255
  29.             PSET (x, y), _RGB32(rNumber, rNumber, rNumber)
  30.             IF _KEYHIT = 27 THEN END '                             escape was pressed to quit
  31.         NEXT
  32.     NEXT
  33.     LINE (150, 150)-(650, 150 + 250 * RND), _RGB32(255, 255, 255), BF 'roll screen a bit
  34.  
  35.     _DISPLAY 'keep flashing from drawing down to minimum
  36.     _LIMIT 60 ' keep to 60 loops per secong
  37.  
« Last Edit: August 03, 2020, 02:52:36 pm by bplus »

Offline AuleMar

  • Newbie
  • Posts: 3
    • View Profile
Re: Sizing screen for graphics
« Reply #2 on: August 03, 2020, 03:10:32 pm »
Thanks for the quick response, Your TV program ran perfect.  But using you code snippets in mine, and it jumped back to the tiny screen again.     I need to run through the code to see if I do anything in it to reset the screen.  last time I ran the code was in 1987.  Its actually amazing that that is the only problem I'm having.  I pulled the programs and data off very old Floppies.

Again thanks.


 

Offline AuleMar

  • Newbie
  • Posts: 3
    • View Profile
Re: Sizing screen for graphics
« Reply #3 on: August 03, 2020, 03:21:53 pm »
Found the culprit it was hiding down in the code (CLS: SCREEN 2, 0, 0) that would snap the screen into tiny mode.  Looks like everything is good now,
Thanks

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sizing screen for graphics
« Reply #4 on: August 03, 2020, 04:10:54 pm »
Good you found the culprit.

I recommend bookmarking this in your browser:
https://www.qb64.org/wiki/Main_Page

You can lookup Keywords Alphabetically AND by usage (categories), usage is very handy if you don't know the name of the Keyword but only have general idea what you want to do. You can do the same from IDE Menu Help (top all the way to right) but On-line the words are hyperlinked slightly easier to access.