Computer Science, asked by hazratarman65, 6 months ago

write a program in Q basic 64 to set the colour of background to red​

Answers

Answered by sridevireddy171816
1

Example 1: Reading the default RGB color settings of color attribute 15.

OUT &H3C7, 15

red% = INP(&H3C9)

green% = INP(&H3C9)

blue% = INP(&H3C9)

PRINT red%, green%, blue%

63 63 63

Example 2: Changing the color settings of attribute 0 (the background) to dark blue in SCREENs 12 or 13.

SCREEN 12

OUT &H3C8, 0 'set color port attribute to write

OUT &H3C9, 0 'red intensity

OUT &H3C9, 0 'green intensity

OUT &H3C9, 30 'blue intensity

OUT &H3C7, 0

PRINT INP(&H3C9); INP(&H3C9); INP(&H3C9)

END

0 0 30

Example 3: Printing in fullscreen SCREEN 0 mode with a color background under the text only.

SCREEN 0: _FULLSCREEN ' used for fullscreen instead of window

COLOR 30, 6: LOCATE 12, 4: PRINT "Hello!"

Result: Hello! is printed in flashing high intensity yellow with brown background behind text only when in Qbasic fullscreen.

Example 4: Using CLS after setting the background color in SCREEN 0 to make the color cover the entire screen.

SCREEN 0: _FULLSCREEN

COLOR , 7: CLS

COLOR 9: PRINT "Hello"

Hello

Result: The blue word Hello is printed to a totally grey background in fullscreen.

Example 5: Using a different foreground color for each letter:

SCREEN 0

COLOR 1: PRINT "H";

COLOR 3: PRINT "E";

COLOR 4: PRINT "L";

COLOR 5: PRINT "L";

COLOR 6: PRINT "O"

COLOR 9: PRINT "W";

COLOR 11: PRINT "O";

COLOR 12: PRINT "R";

COLOR 13: PRINT "L";

COLOR 14: PRINT "D"

HELLO

WORLD

Example 6: Doing the same as Example 5 but in only a few lines:

SCREEN 0

text$ = "HelloWorld"

FOR textpos = 1 TO LEN(text$)

COLOR textpos

IF textpos <> 5 THEN PRINT MID$(text$, textpos, 1);

IF textpos = 5 THEN PRINT MID$(text$, textpos, 1) 'start print on next row

NEXT

Hello

World

Explanation:Semicolon(;) means that the next PRINT happens on the same line, we don't want that when it comes to position 5 so when it is at position 5 the next PRINT will move to the next line (when it isn't at position 5 we want it to continue printing the letter side-by-side on the same line though).

Example 7: Since SCREEN 0 only uses background colors 0 to 7 by default, use _PALETTECOLOR to change color intensities of color 0.

_PALETTECOLOR 0, _RGB32(255, 255, 255) 'change color 0 intensity

_PALETTECOLOR 8, _RGB32(0, 0, 0) 'change color 8 intensity

COLOR 8: PRINT "Black on bright white!"

Black on bright white!

Explanation: Since QB64 does not have DAC SCREEN 0 limitations, changing color intensities for custom background colors is possible.

Example 8: Changing light gray text in SCREEN 0 to a 32 bit custom color using a LONG HTML hexadecimal value:

COLOR 7

PRINT "Color 7 is gray"

K$ = INPUT$(1)

_PALETTECOLOR 7, &HFFDAA520 ' FF alpha makes the color translucent

PRINT "Color 7 is now Goldenrod in SCREEN 0!

Color 7 is gray

Color 7 is now Goldenrod in SCREEN 0!

Explanation: _RGB32 could be used to make custom 32 bit colors or HTML values could be used after &HFF for solid colors.

Similar questions