Color according to density
7 posts • Page 1 of 1
Color according to density
I have a cannon wich takes away density from the target, is it also possible to see a different color according to density?
i tried {e.this.density} at the color in the script menu, but it just turns red
(the script box, not the target)
i tried {e.this.density} at the color in the script menu, but it just turns red
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
-

monstertje3 - Posts: 343
- Joined: Sat Sep 05, 2009 4:29 pm
- Location: N-H, NL
Re: Color according to density
thats because the color hsas 4 values (as colrHSVA has too)
so if you give the color just one value (what density is) , it wont work right
make an oncollide script where you let it act like
if its default (set to density 2) it will stay in its color but if you change the density (like trough a projectile) it will change to what color you want
so if you give the color just one value (what density is) , it wont work right
make an oncollide script where you let it act like
- Code: Select all
density==2?{color=color}:{color=[what,ever,you,want]}
if its default (set to density 2) it will stay in its color but if you change the density (like trough a projectile) it will change to what color you want
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
- Posts: 85
- Joined: Mon Dec 20, 2010 12:02 pm
- Location: Germany
Re: Color according to density
but then it is color A or B, isn't it possible to make it a gradual change?
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
-

monstertje3 - Posts: 343
- Joined: Sat Sep 05, 2009 4:29 pm
- Location: N-H, NL
Re: Color according to density
That would look more like this: color = [{e.this.density/2}, something, something, something]. The /2 is to get the value between 1 and 0.
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: Color according to density
I think this is closer to the script you want (at least the script I'd want):
An odd syntax, I know, but it works. Credit to Gear97.
It initially sets density to very low, then gradually increases it over time. Color is bound to this in that as density increases, color fades from black to red to orange to yellow to white. This simulates the object heating up, as far as color goes.
- Code: Select all
(e.other) -> {
drawBorder = false;
drawCake = false;
controllerAcc = sim.time;
density = {(sim.time - controllerAcc) + 0.00010000000000000000};
color = {[density, density - 8, density - 16, 10] / 10}
}
An odd syntax, I know, but it works. Credit to Gear97.
It initially sets density to very low, then gradually increases it over time. Color is bound to this in that as density increases, color fades from black to red to orange to yellow to white. This simulates the object heating up, as far as color goes.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Color according to density
yay this works, when i put this in the color place, it still turns red (scriptbox), but the target does too, en on lower density it turns black!
Thank you guys!
Edit: it turns red because i selected tracers too (fail)
- Code: Select all
{[density, density - 8, density - 16, 10] / 10}
Thank you guys!
Edit: it turns red because i selected tracers too (fail)
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
-

monstertje3 - Posts: 343
- Joined: Sat Sep 05, 2009 4:29 pm
- Location: N-H, NL
Re: Color according to density
Hmm... The code in my post is intended to be an onCollide script.
This, however, does not work:
Also, I suggest you fool around with my code to see how it works- the color bit anyway.
Keep this in mind: the color array is composed of four parts: [red, blue, green, alpha/transparency].
Each value ranges between 0 and 1. Examples:
[0, 0, 0, 1] = black
[1, 1, 1, 1] = white
[0.5, 0.5, 0.5, 1] = gray
[1, 0, 0, 1] = red
[0.5, 0, 0, 1] = dark red
[1, 0.5, 0.5, 1] = light red
- Code: Select all
(scene.addCircle({pos := e.pos})) -> {
drawBorder = false;
drawCake = false;
controllerAcc = sim.time;
density = {(sim.time - controllerAcc) + 0.00010000000000000000};
color = {[density, density - 8, density - 16, 10] / 10}
}
This, however, does not work:
- Code: Select all
scene.addCircle({
pos := e.pos;
drawBorder := false;
drawCake := false;
controllerAcc := sim.time;
density := {(sim.time - controllerAcc) + 0.00010000000000000000};
color := {[density, density - 8, density - 16, 10] / 10}})
Also, I suggest you fool around with my code to see how it works- the color bit anyway.
Keep this in mind: the color array is composed of four parts: [red, blue, green, alpha/transparency].
Each value ranges between 0 and 1. Examples:
[0, 0, 0, 1] = black
[1, 1, 1, 1] = white
[0.5, 0.5, 0.5, 1] = gray
[1, 0, 0, 1] = red
[0.5, 0, 0, 1] = dark red
[1, 0.5, 0.5, 1] = light red
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests




