![]() |
Forum Index : Microcontroller and PC projects : Random Colours
Author | Message | ||||
asknik2022 Regular Member ![]() Joined: 26/03/2022 Location: United KingdomPosts: 94 |
Is there a way to select a random colour eg white , red ,etc in RGB(colour) I have tried col$="green" in rgb(col$) and get an error Can anyone suggest a work around |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2679 |
The colour names are constants that represent colour numbers, not strings. Try repeatedly:- CLS RGB(RND*255,RND*255,RND*255) |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4068 |
deleted Edited 2023-03-03 09:46 by JohnS |
||||
asknik2022 Regular Member ![]() Joined: 26/03/2022 Location: United KingdomPosts: 94 |
does anyone know what the actual numbers are for the basic colours red,green etc or is there a colour chart of some sort with the actual numbers on. |
||||
asknik2022 Regular Member ![]() Joined: 26/03/2022 Location: United KingdomPosts: 94 |
Solved it via ChatGPT Example below 'Define color lookup table DIM colors$(3) colors$(1)="white": colors$(2)="red": colors$(3)="blue" DIM rgb%(3,3) rgb%(1,1)=255: rgb%(1,2)=255: rgb%(1,3)=255 rgb%(2,1)=255: rgb%(2,2)=0: rgb%(2,3)=0 rgb%(3,1)=0: rgb%(3,2)=0: rgb%(3,3)=255 ' Set color using lookup table colorname$="red" colorindex=0 FOR i=1 TO 3 IF colors$(i)=colorname$ THEN colorindex=i: EXIT FOR NEXT i IF colorindex=0 THEN PRINT "Color not found": END pixel 10,10,rgb(rgb%(colorindex,1),rgb%(colorindex,2),rgb%(colorindex,3)) |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 8043 |
It may look clumsy, but it's obvious what's happening: Create an array c(0)=RGB(black) up to c(15)=RGB(white) Now just use a random number between 0 and 15 because all the colours have simple numbers. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 455 |
To find a color number, you can just PRINT RGB(colorname) > print rgb(red) 4278190335 > print rgb(green) 4278255360 > print rgb(blue) 4294901760 Each of the colors (red, green and blue) can be represented by a number from 0 to 255.You can combine them to create any color in the pallette. print rgb(120,200,17) Edited 2023-03-04 04:40 by toml_12953 |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4068 |
Printing HEX$() of each of those might ... illuminate :) John |
||||
LucV![]() Regular Member ![]() Joined: 19/02/2023 Location: NetherlandsPosts: 62 |
Google is your friend !! In Google just search for color picker and ![]() Move the dot and slider and you can pick any color you want and get RGB, CMYK, HSV and HSL values. Luc's tech Blog |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 8043 |
You *can* but that doesn't mean you can reproduce it on a PicoMite. :) Look in the manual - Appendix F, I think it is. All the available colours and their binary values are listed there. Edited 2023-03-04 05:09 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1270 |
As Picomite VGA uses 4 Bit for the Color Output, there are 16 possible Colors on the PicoMite VGA 1 Bit Red 2 Bit Green and 1 Bit Blue, but, to keep it comatible to MM Basic on other devices, the colors are selected in 24Bit Format. . RRGGBB ------ 000000 0000FF 004000 0040FF 008000 0080FF 00FF00 00FFFF FF0000 FF00FF FF4000 FF40FF FF8000 FF80FF FFFF00 FFFFFF Edited 2023-03-04 06:13 by Martin H. 'no comment |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |