PPRINT lets you print with QB64's built-in screen font in various sizes, not just the default size. I use this little SUB often in my programs because it's small, easy to use, and no external FONT files are needed to make large text sizes. It works by turning printed text to images that _PUTIMAGE can use. Steve has made a better text to image program that blows mine away, so be sure to check his out HERE.
This demo just PPRINT's the DATE$ on the screen in various sizes.
- Dav
This demo just PPRINT's the DATE$ on the screen in various sizes.
- Dav
Code: (Select All)
'==========
'PPRINT.BAS v1.1
'==========
'A SUB that prints larger text sizes using _PUTIMAGE.
'Uses QB64's built-in font, no external FONT needed.
'Coded by Dav, APR/2022
'This demo just prints the DATE$ in various sizes
'=== Set screen mode, and color
SCREEN _NEWIMAGE(600, 600, 32)
'=== draw stuff
FOR x = 1 TO 600 STEP 3
FOR y = 1 TO 600 STEP 3
PSET (x, y), _RGB(RND * 255, RND * 255, RND * 255)
NEXT
NEXT
'=== save background
back& = _COPYIMAGE(_DISPLAY)
'=== cycle DATE$ on screen
DO
CLS , _RGB(32, 32, 32) 'clear
_PUTIMAGE (0, 0), back& 'show background
'pprint date
FOR d = 40 TO 540 STEP 60
size = 20 + RND * 30 'make random sizes
PPRINT 84, d + 4, size, _RGB(1, 1, 1), 0, DATE$ 'this line gives it the shadow
PPRINT 80, d, size, _RGB(RND * 255, RND * 255, RND * 255), 0, DATE$
NEXT
_LIMIT 3 'show 3 pages a second
_DISPLAY 'update display (so it doesn't flicker screen)
LOOP
END
SUB PPRINT (x, y, size, clr&, trans&, text$)
'This sub outputs to the current _DEST set
'It makes trans& the transparent color
'x/y is where to print text
'size is the font size to use
'clr& is the color of your text
'trans& is the background transparent color
'text$ is the string to print
'=== get users current write screen
orig& = _DEST
'=== if you are using an 8 or 32 bit screen
bit = 32: IF _PIXELSIZE(0) = 1 THEN bit = 256
'=== step through your text
FOR t = 0 TO LEN(text$) - 1
'=== make a temp screen to use
pprintimg& = _NEWIMAGE(16, 16, bit)
_DEST pprintimg&
'=== set colors and print text
CLS , trans&: COLOR clr&
PRINT MID$(text$, t + 1, 1);
'== make background color the transprent one
_CLEARCOLOR _RGB(0, 0, 0), pprintimg&
'=== go back to original screen to output
_DEST orig&
'=== set it and forget it
x1 = x + (t * size): x2 = x1 + size
y1 = y: y2 = y + size
_PUTIMAGE (x1 - (size / 2), y1)-(x2, y2 + (size / 3)), pprintimg&
_FREEIMAGE pprintimg&
NEXT
END SUB