Computer Science Canada fading colors help |
Author: | ecookman [ Thu Oct 23, 2008 10:12 am ] | ||
Post subject: | fading colors help | ||
i am wondering if i can get colors in my program to fade from one to the other instead of refreshing.. here is what i have could someone help me ![]() ![]()
p.s the script works i have tried it out it looks like it is messed up but when you run it it isn't so don't change the art ![]() ![]() |
Author: | ecookman [ Thu Oct 23, 2008 10:13 am ] |
Post subject: | RE:fading colors help |
and srry for dubble post if i wasn't clear last time copy and paste it into turing the normalness comes back |
Author: | S_Grimm [ Thu Oct 23, 2008 10:26 am ] |
Post subject: | RE:fading colors help |
whats wrong with it? it changes colour? if you want it to fade, you need to have the colours aranged in a sequence (ie, dark brown, medium brown, light brown, etc) and have it slowley change to that colour. |
Author: | The_Bean [ Thu Oct 23, 2008 12:34 pm ] | ||
Post subject: | Re: fading colors help | ||
|
Author: | ecookman [ Thu Oct 23, 2008 7:07 pm ] |
Post subject: | RE:fading colors help |
umm now how would i apply that to my script |
Author: | andrew. [ Fri Oct 24, 2008 9:34 am ] | ||
Post subject: | RE:fading colors help | ||
The_Bean, you shouldn't just post code, you should also explain it/just help him. There are 2 ways of doing it. One way is easy, but doesn't have really good results. The other is a little harder but looks a lot better. The first way is the way you are doing it now, but instead of a random colour, make it start at a colour and go up by 1 because the colours in Turing are grouped together. Example:
The second way is slightly more challenging and requires you to know a bit about red, green, and blue values. Basically, each colour is made up of red, green, and blue. With RGB, you can choose how much red, green, and blue to add to each pixel. You can learn about the RGB module by pressing F10 in Turing, or by going to the tutorial here. The_Bean has a pretty good example of how you can use it. |
Author: | ecookman [ Fri Oct 24, 2008 7:51 pm ] |
Post subject: | RE:fading colors help |
ummm ill try that |
Author: | ecookman [ Fri Oct 24, 2008 7:54 pm ] |
Post subject: | RE:fading colors help |
o.k why doesn't it work |
Author: | drij [ Sat Oct 25, 2008 3:05 pm ] | ||
Post subject: | Re: fading colors help | ||
Here is a solution I worked out while trying to get my matrix screen to look right. I needed about 40 different shades of green to get things going, but the few that turing has built in to the standard pallet don't fit the bill. I needed them to smoothly fade from green to black.
This solution uses an array of integers (greens) to hold the colour numbers for my new shades of green. Reading up on the RGB module in the Turing help is really worth the effort |
Author: | ecookman [ Mon Oct 27, 2008 7:29 am ] |
Post subject: | RE:fading colors help |
lol i am still like whaaaaaaatttt de le DERRRRRR,,,ummmm...Aaaaaaaaeeerrrrmmmm K? well thanks anyway (confused as hellllllllllll about code... BUT IT WORKS) now is there a way to like mkake it go green then red like a different colors come up like greento black, black to elloy kinda of thing |
Author: | Insectoid [ Mon Oct 27, 2008 11:01 am ] |
Post subject: | RE:fading colors help |
RGB means 'red green blue'. I consists of 3 numbers, the first represents the amount of red, the second green, the third blue. By changing these numbers you can add more blue, or less red, and thus make any color you want. Using a for loop and substituting the for counter into one of the colors, you can create a seamless graduation from one color to another. So a for loop starting at zero substituting into blue will add more blue with each loop. The first will have no blue, just red and green. The next loop 1 blue will be added, then another blue, and so on. Note that the max number of any color is 255. |
Author: | drij [ Mon Oct 27, 2008 1:03 pm ] | ||||||||||
Post subject: | Re: fading colors help | ||||||||||
Here's a more in depth explanation of my code ![]()
The RGB.AddColour function returns an integer. This integer is the colour number for the colour we just created. it assigns the colour number of the current shade of green to greens (i). For an example of how the RGB module works, look at this code:
The loop goes through all 40 items in the array greens and assigns the colour number for greener and greener colours to them. When i = 0, the new colour is black because there is no red, no blue, and since 0 x 0.025 is still 0, no green. But when i = 40, the new colour is bright green because there is no red, no blue, and since 40 x 0.025 1, maximum green. Now we can use greens(0) for black, greens(40) for maximum green, and all the other numbers for everything in between.
The rest of my code is just draws a box with darker and darker shades of green, untill it gets to greens (0), then it cycles through again. You can change the math you use for the arguments in RGB.AddColour to get whatever colours you want. I used 0.0, i x 0.025, and 0.0 as the arguments I passed to RGB.AddColour, but by changing these numbers, you can fade to different colors from black. Fading from colours other than black would be trickier though. This is just how I do fades. I'm sure that If anyone gives it a bit of effort, the could do it better than me ![]() |
Author: | ecookman [ Fri Oct 31, 2008 7:22 am ] |
Post subject: | RE:fading colors help |
lol thanks for the mini tutorial, but i am not quite sure how i would change the math to make it different colors so it goes from one to the other |
Author: | drij [ Fri Oct 31, 2008 11:55 am ] |
Post subject: | Re: fading colors help |
EDIT: Here is a little program that outputs the Turing code to make a fade between any two colours. You just need to input the Hexadecimal colour codes and the number of shades you want in between. |