How to set color for rectangles in graphics mode in x16 basic?

All aspects of programming on the Commander X16.
Post Reply
KaiLikesToCode
Posts: 6
Joined: Sun Sep 17, 2023 2:28 pm

How to set color for rectangles in graphics mode in x16 basic?

Post by KaiLikesToCode »

I have some code to draw a grid of rects:

Code: Select all

start:
	screen 128
	goto loop
	
loop:
	for i=1 to 5
	for j=1 to 5
	color rnd(1)*15
	rect i*25,j*25,i+15, j+15
	next j
	next i
	goto loop
But using the color command seems to not change the color of the rect color in graphics mode.
User avatar
ahenry3068
Posts: 1131
Joined: Tue Apr 04, 2023 9:57 pm

Re: How to set color for rectangles in graphics mode in x16 basic?

Post by ahenry3068 »

KaiLikesToCode wrote: Tue Jan 09, 2024 9:10 pm I have some code to draw a grid of rects:

Code: Select all

start:
	screen 128
	goto loop
	
loop:
	for i=1 to 5
	for j=1 to 5
	color rnd(1)*15
	rect i*25,j*25,i+15, j+15
	next j
	next i
	goto loop
But using the color command seems to not change the color of the rect color in graphics mode.
Color only changes the text mode, also it is limited to the values 0-15.

You want a 5th parameter after RECT as the color. so RECT X1,Y1,X2,Y2, COLOR. And it can be between 0 and 255.

Heres the default colors. You can change them(palette manipulation) but play with the defaults before you worry about that.
VERASCRN.png
VERASCRN.png (18.07 KiB) Viewed 13371 times
Post Reply