Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / calculating rainbow colors

Author
Message
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Sep 2009 14:56
Hello everyone!

Why won't this compile?



I would like to make an image with the colors red, yellow, orange, light blue, blue and green fading into each other. I thought the statement "(x>y and a<b)*c" would work, but it doesn't... Please help!

TheComet


Make the paths of your enemies easier with WaypointPro!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Sep 2009 15:26 Edited at: 13th Sep 2009 16:15
It's probably best to do it with 5 loops, one for each fade rather than trying to be too compact. You could do it with a start colour, and end colour, and a bit like an object moving to another object it is the same code. The next loop would start with the end colour of the first loop, but moved up a line in the Y.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Sep 2009 16:55 Edited at: 13th Sep 2009 17:24
Here's where I get to be like TDK and show you the code I wrote 90 years ago to do this very thing...

I don't seem to have posted this before so I'm not sure if it's right, just typing from memory.
The function takes a single integer; 0-255 gives a rainbow, going beyond 255 goes into yellow and magenta colours.

[edit]
The problem with mine is that as soon as one colour starts increasing another decreases meaning you never get a bright yellow for example.
I haven't worked out how to get an overlap like this;
red high, green low, blue low
red high, green high, blue low
red low, green high, blue low
red low, green high, blue high
red low, green low, blue high
(and wrapping)
red high, green low, blue high

When someone works out how to do that it will be perfect.

TGC Forum - converting error messages into sarcasm since 2002.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Sep 2009 17:14
heres what i would do, put all the different colors xcept the starting one into data statements and then into an array

then use this function to scroll from one to the next, two nested for-next loops (outer for different colors and inner for percent)

startcolor and endcolor are the colors AFTER THEY'VE GONE THROUGH RGB()

the function accepts two colors and a percent value (0-100) and will output a color x percent of the way from color a to color b



TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Sep 2009 21:30
Thanks everyone, but I don't think you quite understand what I am angling for, since I didn't describe it correctly... This is what I want in the end:



If I were to unwrap this texture, it would be the colors red fading into green on the y axis, and on the x axis orange, yellow, blue and light-blue fading into each other. This is a very stupid image of displaying this:



The image would look like that, only with those colors fading into each other accordingly... How would I do this?

TheComet


Make the paths of your enemies easier with WaypointPro!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Sep 2009 21:33 Edited at: 13th Sep 2009 21:39
Easiest way is with Photoshop, saves messing around. But really it is the same code but with adaptable X/Y coordinates.

If you want me to Photoshop it tell me the size, and I will do it. Also tell me if it is seamless, yellow to blue.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Sep 2009 21:46
That would be great, Pincho! The image would have to be 512*512*32 and seamless. I'm in no rush, please take your time.

TheComet


Make the paths of your enemies easier with WaypointPro!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Sep 2009 22:33

Again haven't tested but is that what you wanted?
Or do you want the red, green and blue fading in from the corners?
btw blue comes after green in the rainbow.

TGC Forum - converting error messages into sarcasm since 2002.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Sep 2009 22:45
Off topic:

Comet:

Funny thing is if you got that image off line then someone did that really easily with dx. hahaha cuz in dx you just color each vertex and it does the fading by itself

New Site! Check it out \/
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Sep 2009 22:53 Edited at: 13th Sep 2009 22:58
I think that this is right, it wraps in all directions, wasn't quite sure how much Rainbow to use on it. Not quite sure if the UV map is in the right order either.

Attachments

Login to view attachments
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Sep 2009 22:58 Edited at: 13th Sep 2009 23:21
@Pincho
Did you generate that in DBC?

I wrote a program a while ago that would diffuse coloured "gas" in a grid of cells, it produced the effect that you want but a straight forward formula would be a lot quicker. I'll see if I can find it...

[edit]
Can't find it but like I said it would be really slow anyway.

TGC Forum - converting error messages into sarcasm since 2002.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Sep 2009 23:00
No I did it in Photoshop. I just diffused the colours, but I don't think that they are in the right order. In fact I think that this requires a spherical UV map.

That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Sep 2009 23:57
just a random thought, but you could make a memblock of the object's mesh and slowly mutate the UV data of the memblock, this would give the impression of the texture moving on the object and if properly done it could provide the proper results mayb

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Sep 2009 00:42
This is a different style of UV Map, using Cubed stretched to the 4 corners of the map.

Attachments

Login to view attachments
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Sep 2009 00:46
This is the before example of how it was mapped.

Attachments

Login to view attachments
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 14th Sep 2009 00:46
The screen you posted shows a cube with different colours per vertex, it's certainly not a texture. Since it's DBC, I'm not sure if it's doable, but mesh memblocks might allow you to set the vertex colour.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Sep 2009 07:16
Here is a 3D cube UV Mapped with a Rainbow.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-09 14:50:26
Your offset time is: 2024-05-09 14:50:26