A "random" Color

About advanced scenes, and the Thyme scripting language used in Algodoo.

A "random" Color

Postby Rideg » Sat Jun 12, 2010 12:53 pm

Hello I'm wondering if there's a way to spawn circles with this color: [1.0, random color, 0.0, 0.7].

Is there a way to declare just the (0), (2) and (3) parts and let the (1) part be random?
EDIT-----------------------------------------
Without using any scene.my.* variables
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: A "random" Color

Postby Chronos » Sat Jun 12, 2010 3:26 pm

You could try sin(scene.Time) for (1).
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: A "random" Color

Postby Rideg » Sat Jun 12, 2010 6:18 pm

okey It'll work thank you.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: A "random" Color

Postby REMqb » Sat Jun 12, 2010 6:31 pm

Another way to do this :
Code: Select all
(e)=>{
    object = Scene.addCircle({
        radius := 0.05;
        pos := e.pos;
    });
    object.color = [1.0, object.color(1), 0.0, 0.7];
}
REMqb
 
Posts: 15
Joined: Wed Dec 30, 2009 7:51 pm
Location: France

Re: A "random" Color

Postby Rideg » Sat Jun 12, 2010 8:41 pm

okey thanks I'll try that in a sec :thumbup:
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: A "random" Color

Postby Rideg » Sat Jul 10, 2010 11:13 pm

Okey well instead of making a new thread I'll bump this one :D. Is there a way to limit REMqb's way so it the color will be random within specific parameters. Here's what I wrote:
Code: Select all
(e)=>{
    object = Scene.addCircle({
        radius := 0.05;
        pos := e.pos
    });
    object.color = [object.color(0), object.color(0), object.color(0), 1.0]
}
- A raondom grayscale object. Could I make like a "color limiter" so it wont reach almost white or black and be random between object.color = 0.3 and 0.5?

Sorry for the bump.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: A "random" Color

Postby REMqb » Sun Jul 11, 2010 2:40 pm

replace object.color(0) by (object.color(0)*(max-min)+min)

you will get :
Code: Select all
(e)=>{
    object = Scene.addCircle({
        radius := 0.05;
        pos := e.pos
    });
    grey = (object.color(0) * (0.5 - 0.3) + 0.3);
    object.color = [grey, grey, grey, 1.0]
}
REMqb
 
Posts: 15
Joined: Wed Dec 30, 2009 7:51 pm
Location: France

Re: A "random" Color

Postby Kilinich » Mon Jul 12, 2010 9:18 am

I think now (in 1.7.4) you can use Palette so just set it do desire value in script.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: A "random" Color

Postby RA2lover » Sat Jul 17, 2010 2:18 am

but it only allows for HSVA limiting, instead of RGBA.
Jrv wrote:
TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.


GTFO newfgt
User avatar
RA2lover
 
Posts: 607
Joined: Mon Aug 31, 2009 8:43 pm
Location: Brazil

Re: A "random" Color

Postby Rideg » Sat Jul 17, 2010 3:22 am

Okey thanks I'll try it tomorrow :D
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests