|
Post by n00b on Nov 25, 2020 9:27:19 GMT -6
Make sure you are on the correct canvas with the Canvas() function.
Also ClearCanvas does not clear commands that draw directly to the window like PrintS, InputS, and ZoneInputS. To clear those you will need to use Cls().
|
|
|
Post by rosy on Dec 2, 2020 7:59:56 GMT -6
How to change the color of the canvas?
|
|
|
Post by johnno56 on Dec 2, 2020 14:12:06 GMT -6
I can tell you you how "I" do it....
First: I reference the canvas (let's assume that it is canvas #3) Second: Choose a color: example - Yellow Third: Draw a filled rectangle'
Canvas(3) setColor(rgb(255,255,0)) BoxFill(0,0,canvaswidth,canvasheight)
I usually put this in a function/subroutine.
There is probably a better way to do it, but that is the method I use.
I hope I have helped....
J
|
|
|
Post by n00b on Dec 2, 2020 18:23:13 GMT -6
The easiest method is to use SetClearColor(). You can find it under "Window Management" in the manual.
|
|
|
Post by johnno56 on Dec 3, 2020 1:47:50 GMT -6
Cool.. One command. I knew there was a better way! Thanks n00b.
|
|
|
Post by n00b on Dec 3, 2020 9:02:04 GMT -6
I probably should add this to the Canvas section as well as the Window Management section. The manual says it works with Cls but it does also work with ClearCanvas. The manual will always be a work in progress.
|
|
|
Post by rosy on Dec 3, 2020 13:11:56 GMT -6
There is a completely different description in the manual
|
|
|
Post by n00b on Dec 3, 2020 16:58:24 GMT -6
I will make a note to fix this in the manual. Originally it did only work with Cls but that changed a few versions ago.
|
|
|
Post by johnno56 on Dec 5, 2020 15:53:46 GMT -6
Here is a quick and dirty test.
Set canvas(0) to full screen: Set canvas(1) to a smaller section:
Set focus on canvas(0) and setClearColor to Orange. cls() Wait for keypress. Set focus on canvas(1) and setClearColor to Yellow cls() Wait for keypress
(I tried both cls() and clearcanvas)
Regardless of the colour and the canvas, setClearColor, seem to work only on the entire screen. Maybe I did something wrong?
xmax = 1366 ymax = 768 title$ = "Clear Colour Test"
WindowOpen(0,title$,0,0,xmax,ymax,1) CanvasOpen(0,xmax,ymax,0,0,xmax,ymax,1) Canvas(0) setClearColor(rgb(255,128,0)) clearcanvas 'cls() update()
waitkey
CanvasOpen(1,570,420,54,18,570,420,0) canvas(1) setClearColor(rgb(255,255,0)) clearcanvas 'cls() update()
waitkey
|
|
|
Post by n00b on Dec 7, 2020 3:14:57 GMT -6
Hey Johnno, sorry for the late reply. I was crunching on this latest release all weekend.
To answer your question, setClearColor is working for you. The issue is a behavior in RCBasic when update is called. When update is called, the renderer clears the backbuffer before drawing the new frame. So the backbuffer will get cleared to the current clear color.
Just change your clear color back to black before you call update.
|
|
|
Post by rosy on Dec 7, 2020 4:40:32 GMT -6
I mean, what should the code look like? Because nothing changes for me ... It looks like what I was afraid of - only the black color is transparent. Can this be changed?
|
|
|
Post by n00b on Dec 7, 2020 9:07:06 GMT -6
Here is johnno56 example with some modifications. I added notes on the stuff I changed. xmax = 1366 ymax = 768 title$ = "Clear Colour Test" WindowOpen(0,title$,WINDOWPOS_CENTERED,WINDOWPOS_CENTERED,xmax,ymax,0) CanvasOpen(0,xmax,ymax,0,0,xmax,ymax,1) Canvas(0) setClearColor(rgb(255,128,0)) clearcanvas 'cls() 'Change Clear Color back before UPDATE SetClearColor(0)
update() waitkey CanvasOpen(1,570,420,54,18,570,420,1)
'Canvas 1 by default will be drawn behind Canvas 0 'To change this we use the SetCanvasZ function SetCanvasZ(0, 2)
canvas(1) setClearColor(rgb(255,255,0)) clearcanvas 'cls()
'Change Clear Color back before UPDATE SetClearColor(0)
update() waitkey
|
|
|
Post by rosy on Dec 7, 2020 10:56:36 GMT -6
But we wanted to display Canvas1 under transparent Canvas0.
|
|
|
Post by n00b on Dec 7, 2020 11:05:22 GMT -6
You could use RGBA to set the alpha value during SetClearColor. But changing the alpha value will blend the color with the colors below it. An alpha value of 0 is completely transparent which means you will see through the canvas entirely.
|
|
|
Post by rosy on Dec 7, 2020 16:00:54 GMT -6
as I enter setClearColor (rgba (255,128,0,0)) it is black instead of orange
|
|