QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Joshua on December 31, 2018, 04:09:42 pm

Title: [SOLVED] Weird graphics artifact using WINDOW
Post by: Joshua on December 31, 2018, 04:09:42 pm
I like having the Cartesian coordinates with the origin in the lower left for graphics, so I'll use the WINDOW statement like so:
Code: QB64: [Select]
  1. CONST winWidth = 800
  2. CONST winHeight = 600
  3.  
  4. SCREEN _NEWIMAGE(winWidth, winHeight, 32)
  5. WINDOW (0, 0)-(winHeight - 1, winWidth - 1)
  6.  
  7. FOR x = 0 TO winWidth
  8.     LINE (x, 100)-(x, 300), _RGB(127, 127, 127)
  9.  


But you'll notice when you run the code there is some sort of underflow error when the lines are displayed, as there are gaps.  If you remove the WINDOW statement, it correctly makes a solid bar.  Is there another way to move 0,0 to the lower left without this artifact?
Title: Re: Weird graphics artifact using WINDOW
Post by: RhoSigma on December 31, 2018, 04:22:40 pm
Remove the WINDOW statement, instead make your Y coordinates a diff to the height:

LINE (x, winHeight - 100)-(x, winHeight - 300), _RGB(127, 127, 127)
Title: Re: Weird graphics artifact using WINDOW
Post by: FellippeHeitor on December 31, 2018, 04:32:37 pm
Whatever it is doing, it's just what it's supposed to do since that's exactly what QB4.5 would do.

Code: QB64: [Select]
  1. CONST winWidth = 320
  2. CONST winHeight = 200
  3.  
  4. WINDOW (0, 0)-(winHeight - 1, winWidth - 1)
  5.  
  6. FOR x = 0 TO winWidth
  7.     LINE (x, 100)-(x, 300), 7

The above version will do basically the same (sans QB64 specific commands) and works with QB4.5 - the result is exactly the same type of artifact as you can see below, likely something with stretching or similar:

 [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Weird graphics artifact using WINDOW
Post by: Joshua on December 31, 2018, 04:46:59 pm
Everything is working fine.  I made a mistake.  In the WINDOW statement, the winWidth and winHeight values are backwards

The right code:
Code: QB64: [Select]
  1. WINDOW (0, 0)-(winWidth- 1, winHeight- 1)
  2.  
Title: Re: [SOLVED] Weird graphics artifact using WINDOW
Post by: FellippeHeitor on December 31, 2018, 05:02:48 pm
Good to hear it's solved :-)