fading colors help
Author |
Message |
ecookman
|
Posted: 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
Turing: |
% window size
var win : int := Window.Open ("graphics:700;550")
%color var
var c : int
loop
delay (80)
colorback (black)
cls
c := Rand.Int (1 , 255)
color (c )
put" _____ _____"
put" |00000| |00000|"
put" |00000| |00000|"
put" |000__| |__000|"
put" |000| |000|"
put" /0000| |0000\\"
put" /00000| |00000\\"
put" |0000000\\ /0000000|"
put" |00000000__________00000000|"
put" __________________|00000000000000000000000000|"
put" /00000000000000000000/0000 T H E L E G E N D O F"
put" /00___________00000000__________________ _________ __"
put" /0/ /00*00/ \\0000000000|\\0000/ \\000|\\00\\ \\0\\"
put" /_/ /00*00/ |00_____00| |00| |00| \\00\\ /00\\"
put" /0* *0/ |00| \\0| |00| |00| \\00\\ /0000\\"
put" /00*00/ |00| /| \\| |00| |00| |00| /0/\\000\\"
put" /00000/ |00|__0| |00| |00| |00| /0/ \\000\\"
put" /00*00/ |00|__0| |00| |00| |00|/00____0000\\"
put" /0* *0/ |00| \\| |00| |00| /00//00 ____00000\\"
put" /00* 0/ |00| /| |00| /| |00| /00//000/ \\000000\\"
put" /00000/ |00======0| |00|___0| |00|/00//000/ \\000000\\"
put" /00*00/ |000000000|/00000000|/000000//0000\\ /0000000\\"
put" /0* *0/ //================================================\""
put" /00*00/ // /0000000000000000\\"
put" /00*00/____________// /000000000000000000\\"
put" /0000000000000000000/ /0/ T W I L I G H T P R I N C E S S"
put" /0000000000000000000/ \\| /00000| |000000\\"
put" \\/0000| |00000\\/"
put" |00| |00|"
put" |00| |00|"
put" |00| |00|"
put" |00| |00|"
put" == =="
end loop
|
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
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
ecookman
|
Posted: 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
|
|
|
|
|
|
S_Grimm
|
Posted: 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.
|
|
|
|
|
|
The_Bean
|
Posted: Thu Oct 23, 2008 12:34 pm Post subject: Re: fading colors help |
|
|
Turing: |
for i : 0 .. 100
Draw.FillBox (0, 0, maxx, maxy, RGB.AddColour (i / 100, 0, 0))
delay (20)
end for
%RGB.AddColor (redComp, greenComp, blueComp : real) : int
%Turings max colour is 255 RGB.AddColour extends this, but starts to mess up after 1000
|
|
|
|
|
|
|
ecookman
|
Posted: Thu Oct 23, 2008 7:07 pm Post subject: RE:fading colors help |
|
|
umm now how would i apply that to my script
|
|
|
|
|
|
andrew.
|
Posted: 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:
Turing: |
loop
cls
colorback (black)
for i : 31.. 16 %This starts at grey and goes to black
c := i %The colour is whatever colour the for loop is on
end for
color (c )
put "This is a colour"
end loop
|
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.
|
|
|
|
|
|
ecookman
|
Posted: Fri Oct 24, 2008 7:51 pm Post subject: RE:fading colors help |
|
|
ummm ill try that
|
|
|
|
|
|
ecookman
|
Posted: Fri Oct 24, 2008 7:54 pm Post subject: RE:fading colors help |
|
|
o.k why doesn't it work
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
drij
|
Posted: 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.
Turing: | View.Set ("graphics:200;200,offscreenonly,nobuttonbar")
var greens : array 0 .. 40 of int
for i : 0 .. 40
greens (i ) := RGB.AddColour (0. 0, i * 0. 025, 0. 0)
/*0.025 because 0.025 * 40 = 1 so greens (40) gives the colour number for pure green while
greens (0) gives the colour number for black */
end for
loop
for decreasing i : 40 .. 0
Draw.FillBox (0, 0, maxx, maxy, greens (i ))
View.Update
delay (30)
end for
delay (500)
end loop
|
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
|
|
|
|
|
|
ecookman
|
Posted: 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
|
|
|
|
|
|
Insectoid
|
Posted: 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.
|
|
|
|
|
|
drij
|
Posted: Mon Oct 27, 2008 1:03 pm Post subject: Re: fading colors help |
|
|
Here's a more in depth explanation of my code
Turing: | View.Set ("graphics:200;200,offscreenonly,nobuttonbar") | This sets the screen size to 200 x 200 px, removes the button bar, and changes the graphics mode to double buffering to make animation smoother.
Turing: | var greens : array 0 .. 40 of int | This creates a 1 x 40 array of integers.
Turing: | for i : 0 .. 40
greens (i ) := RGB.AddColour (0. 0, i * 0. 025, 0. 0)
end for | This loop is very important. It uses the RGB module to create all the colours that we need for our fade.
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:This creates a new colour that has a red level of 0.9 out of 1, a green level of 0.5 out of 1, and a blue level of 0.1 out of 1. It returns the colour number for this new colour and assigns it to myNewColour. To use this colour, we just have to use myNewColour as the colour of any object or text that we draw or write.
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
|
|
|
|
|
|
ecookman
|
Posted: 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
|
|
|
|
|
|
drij
|
Posted: 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.
Description: |
|
Download |
Filename: |
Fadehelp.t |
Filesize: |
2.58 KB |
Downloaded: |
53 Time(s) |
|
|
|
|
|
|
|
|