PAINT command

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
rishu
Newbie
Posts: 7
Joined: Thu Jul 17, 2008 4:48 am
Location: indyeah

PAINT command

Post by rishu »

open help. and then explore paint command. I am unable to understand the usage of tile$ and background$.
MilesAway1980
Coder
Posts: 25
Joined: Tue Jul 29, 2008 12:30 pm

Post by MilesAway1980 »

I've never taken the time to figure out the background, but the tile is pretty easy.

Basically what the tile is is that instead of painting one solid color, you can paint with a pattern.

For example:

Screen 13

'make a shape
DRAW "c4 bm 50, 50 r50f50l50h50"

'create a "tile"
TileInfo$ = CHR$(15) + CHR$(17) + CHR$(19) + CHR$(21) + CHR$(23)
PAINT (65,55), TileInfo$, 4



Give that a try and it'll show you how that works.
Basically what it does is create a pattern that, in this example, is striped colors 15, 17, 19, 21, and 23 repeated over and over again. It looks like you can only do horizontal stripes and not vertical.
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

I have never used PAINT before, so, you made me do some experimenting!

For instance, after a while, I tried CHR$(65) + CHR$(66), then "A" + "B", and, finally, just "AB". Finally, I was using "aaagggooowww". Yes, all horizontal lines. Hmm...

...finally, I changed SCREEN 13 to SCREEN 12, and, I know it sounds strange, but, I now see only VERTICAL lines in SCREEN 12! Further, screens 7, 8, 9, 10, 11, and 12 ALL give vertical lines, only SCREEN 13 shows them horizontaly!

I'll lkeave futher exerimentation up to you guys. Have fun.

Oh, I even tried strings like, " gggg", yeah, just 5 spaces works fine, same as using CHR$(32) + CHR$(32)+ CHR$(32)+ CHR$(32), only, much easier to use the string, " ". Sort of opens up a whole new frontier, what with the whole 256 characters available!!!
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
angros47
Veteran
Posts: 79
Joined: Mon Sep 08, 2008 12:52 pm
Contact:

Post by angros47 »

The usage depends of screen mode.

In monochrome (screen 2, screen 11...) the usage is very easy:
The tile MUST have a width of 8 bit, and can have a variable height.
You draw the tile by converting the bit-matrix to bytes.

Example (drawing a cross):
00001000=8
00001000=8
00001000=8
11111111=255
00001000=8
00001000=8
00001000=8

So the program:

Code: Select all

screen 11
paint (10,10),chr$(8)+chr$(8)+chr$(8)+chr$(255)+chr$(8)+chr$(8)+chr$(8)
Will draw a "grid" (tiled crosses)

In 16 color modes, every line is 4-byte long (2^4=16): one byte sets the red attribute, one the green, one the blue, one the brightess of the eight pixels of the line.

In 256-color mode, you will need 8 bytes for every line (2^8=256).
So you can't use the same tile string in different screen modes unless they have the same number of colors (i.e. screen 7,8,12 are compatible)
Post Reply