Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Corrupted printing
#1
I have written the section of code below in one of my progs. It draws a "dartboard" target, and places a letter in each segment of the target.
On the first loop , it does this correctly, but on successive loops, segments 3 and 4, and 9 and 10, have a section of the letter rendered in black.
As far as I can see, the result should be the same each time.
I think it's something to do with the Paint lines.
What am I missing?
Code: (Select All)
Screen _NewImage(1040, 768, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 20, "monospace"): _Font f&
SMode = 32
Common Shared letr$(), numletrs
Dim letr$(10): numletrs = 10
Randomize Timer
For a = 1 To 5
    target
    Sleep
Next

Sub target
    For a = 1 To numletrs
        letr$(a) = Chr$(Int(Rnd * 26) + 65)
    Next
    Color _RGB(255, 255, 255)
    Draw "ta0"
    Locate 15, 40: Print letr$(1)
    Locate 14, 44: Print letr$(2)
    Locate 18, 40: Print letr$(3)
    Locate 14, 35: Print letr$(4)
    Circle (510, 288), 38
    Circle (510, 288), 98
    Paint (520, 290), _RGB(100, 20, 20), _RGB(255, 255, 255) '                     segment 1
    Paint (590, 290), _RGB(20, 100, 20), _RGB(255, 255, 255) '                     segment 2,3,4
    PSet (510, 250): Draw "u60"
    PSet (544, 306): Draw "ta240u60"
    PSet (476, 306): Draw "ta120u60"
    Locate 9, 40: Print letr$(5)
    Locate 18, 48: Print letr$(6)
    Locate 18, 31: Print letr$(7)
    Circle (510, 288), 159
    PSet (648, 212): Draw "ta120u60"
    PSet (510, 447): Draw "ta0u59"
    PSet (372, 213): Draw "ta240u60"
    Paint (410, 290), _RGB(20, 20, 100), _RGB(255, 255, 255) '                    segment 5,6,7
    Locate 11, 53: Print letr$(8)
    Locate 24, 40: Print letr$(9)
    Locate 11, 27: Print letr$(10)
    Circle (510, 288), 218
    Paint (671, 290), _RGB(100, 20, 100), _RGB(255, 255, 255) '                   segment 8,9,10
    PSet (510, 130): Draw "ta0u60"
    PSet (374, 365): Draw "ta120u60"
    PSet (650, 365): Draw "ta240u60"
End Sub
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#2
Code: (Select All)
Screen _NewImage(1040, 768, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 20, "monospace"): _Font f&
SMode = 32
Common Shared letr$(), numletrs
Dim letr$(10): numletrs = 10
Randomize Timer
For a = 1 To 5
    target
    Sleep
Next

Sub target
    _PrintMode _KeepBackground

    For a = 1 To numletrs
        letr$(a) = Chr$(Int(Rnd * 26) + 65)
    Next

    'One of these two fixes:
    _PrintMode _KeepBackground
    'OR
    Color _RGB(255, 255, 255), 0
    'Either of the above will fix the issue.  Just correct your COLOR or _PRINTMODE when exiting the SUB
    Draw "ta0"
    Locate 15, 40: Print letr$(1)
    Locate 14, 44: Print letr$(2)
    Locate 18, 40: Print letr$(3)
    Locate 14, 35: Print letr$(4)
    Circle (510, 288), 38
    Circle (510, 288), 98
    Paint (520, 290), _RGB(100, 20, 20), _RGB(255, 255, 255) '                    segment 1
    Paint (590, 290), _RGB(20, 100, 20), _RGB(255, 255, 255) '                    segment 2,3,4
    PSet (510, 250): Draw "u60"
    PSet (544, 306): Draw "ta240u60"
    PSet (476, 306): Draw "ta120u60"
    Locate 9, 40: Print letr$(5)
    Locate 18, 48: Print letr$(6)
    Locate 18, 31: Print letr$(7)
    Circle (510, 288), 159
    PSet (648, 212): Draw "ta120u60"
    PSet (510, 447): Draw "ta0u59"
    PSet (372, 213): Draw "ta240u60"
    Paint (410, 290), _RGB(20, 20, 100), _RGB(255, 255, 255) '                    segment 5,6,7
    Locate 11, 53: Print letr$(8)
    Locate 24, 40: Print letr$(9)
    Locate 11, 27: Print letr$(10)
    Circle (510, 288), 218
    Paint (671, 290), _RGB(100, 20, 100), _RGB(255, 255, 255) '                  segment 8,9,10
    PSet (510, 130): Draw "ta0u60"
    PSet (374, 365): Draw "ta120u60"
    PSet (650, 365): Draw "ta240u60"
End Sub

Exact same issue I was talking about here: https://qb64phoenix.com/forum/showthread...7#pid34867
Reply
#3
(07-08-2025, 03:10 AM)SMcNeill Wrote:
Code: (Select All)
Screen _NewImage(1040, 768, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 20, "monospace"): _Font f&
SMode = 32
Common Shared letr$(), numletrs
Dim letr$(10): numletrs = 10
Randomize Timer
For a = 1 To 5
    target
    Sleep
Next

Sub target
    _PrintMode _KeepBackground

    For a = 1 To numletrs
        letr$(a) = Chr$(Int(Rnd * 26) + 65)
    Next

    'One of these two fixes:
    _PrintMode _KeepBackground
    'OR
    Color _RGB(255, 255, 255), 0
    'Either of the above will fix the issue.  Just correct your COLOR or _PRINTMODE when exiting the SUB
    Draw "ta0"
    Locate 15, 40: Print letr$(1)
    Locate 14, 44: Print letr$(2)
    Locate 18, 40: Print letr$(3)
    Locate 14, 35: Print letr$(4)
    Circle (510, 288), 38
    Circle (510, 288), 98
    Paint (520, 290), _RGB(100, 20, 20), _RGB(255, 255, 255) '                    segment 1
    Paint (590, 290), _RGB(20, 100, 20), _RGB(255, 255, 255) '                    segment 2,3,4
    PSet (510, 250): Draw "u60"
    PSet (544, 306): Draw "ta240u60"
    PSet (476, 306): Draw "ta120u60"
    Locate 9, 40: Print letr$(5)
    Locate 18, 48: Print letr$(6)
    Locate 18, 31: Print letr$(7)
    Circle (510, 288), 159
    PSet (648, 212): Draw "ta120u60"
    PSet (510, 447): Draw "ta0u59"
    PSet (372, 213): Draw "ta240u60"
    Paint (410, 290), _RGB(20, 20, 100), _RGB(255, 255, 255) '                    segment 5,6,7
    Locate 11, 53: Print letr$(8)
    Locate 24, 40: Print letr$(9)
    Locate 11, 27: Print letr$(10)
    Circle (510, 288), 218
    Paint (671, 290), _RGB(100, 20, 100), _RGB(255, 255, 255) '                  segment 8,9,10
    PSet (510, 130): Draw "ta0u60"
    PSet (374, 365): Draw "ta120u60"
    PSet (650, 365): Draw "ta240u60"
End Sub

Exact same issue I was talking about here: https://qb64phoenix.com/forum/showthread...7#pid34867

Thanks Steve.
I've tried the _Keepbackground, but it leaves the previous letter under the new one.
Fiddling with printing Chr$(32) first, and other remedies - no luck yet.
Edit: Looks like _ClearColor may be what I need. It kills some segments at present, but may be the way to go. Thank you.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#4
(07-08-2025, 03:57 AM)PhilOfPerth Wrote:
(07-08-2025, 03:10 AM)SMcNeill Wrote:
Code: (Select All)
Screen _NewImage(1040, 768, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 20, "monospace"): _Font f&
SMode = 32
Common Shared letr$(), numletrs
Dim letr$(10): numletrs = 10
Randomize Timer
For a = 1 To 5
    target
    Sleep
Next

Sub target
    _PrintMode _KeepBackground

    For a = 1 To numletrs
        letr$(a) = Chr$(Int(Rnd * 26) + 65)
    Next

    'One of these two fixes:
    _PrintMode _KeepBackground
    'OR
    Color _RGB(255, 255, 255), 0
    'Either of the above will fix the issue.  Just correct your COLOR or _PRINTMODE when exiting the SUB
    Draw "ta0"
    Locate 15, 40: Print letr$(1)
    Locate 14, 44: Print letr$(2)
    Locate 18, 40: Print letr$(3)
    Locate 14, 35: Print letr$(4)
    Circle (510, 288), 38
    Circle (510, 288), 98
    Paint (520, 290), _RGB(100, 20, 20), _RGB(255, 255, 255) '                    segment 1
    Paint (590, 290), _RGB(20, 100, 20), _RGB(255, 255, 255) '                    segment 2,3,4
    PSet (510, 250): Draw "u60"
    PSet (544, 306): Draw "ta240u60"
    PSet (476, 306): Draw "ta120u60"
    Locate 9, 40: Print letr$(5)
    Locate 18, 48: Print letr$(6)
    Locate 18, 31: Print letr$(7)
    Circle (510, 288), 159
    PSet (648, 212): Draw "ta120u60"
    PSet (510, 447): Draw "ta0u59"
    PSet (372, 213): Draw "ta240u60"
    Paint (410, 290), _RGB(20, 20, 100), _RGB(255, 255, 255) '                    segment 5,6,7
    Locate 11, 53: Print letr$(8)
    Locate 24, 40: Print letr$(9)
    Locate 11, 27: Print letr$(10)
    Circle (510, 288), 218
    Paint (671, 290), _RGB(100, 20, 100), _RGB(255, 255, 255) '                  segment 8,9,10
    PSet (510, 130): Draw "ta0u60"
    PSet (374, 365): Draw "ta120u60"
    PSet (650, 365): Draw "ta240u60"
End Sub

Exact same issue I was talking about here: https://qb64phoenix.com/forum/showthread...7#pid34867

Thanks Steve.
I've tried the _Keepbackground, but it leaves the previous letter under the new one.
Fiddling with printing Chr$(32) first, and other remedies - no luck yet.
Edit: Looks like _ClearColor may be what I need. It kills some segments at present, but may be the way to go. Thank you.

Eureka! (I think)
I've found if I paint the cell first, then print the letter, with the background color set to the paint color I used, it seems to work.
Need to check a bit more before I break out the ginger beer though!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  need help printing a scaled string in a custom font to a 32-bit image madscijr 9 1,147 07-03-2025, 04:48 PM
Last Post: SMcNeill
  Corrupted QB45 saved program Cobalt 11 1,510 06-13-2025, 12:13 AM
Last Post: luke
  printing characters > chr$(127) madscijr 18 2,126 03-11-2025, 07:33 PM
Last Post: madscijr
  Printing to my Printer Dimster 17 6,937 07-14-2022, 06:54 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)