change color

Asked by jamespaul on 2019-05-23

hello

I want to color the particles by region.But I found that only the combination of 255 and 0 can change color,such as (255, 0, 255)(0, 255, 255)(0,0,0).If I use other combination ,the color will be white.Is it because yade only shows a few colors?

I would appreciate if you can help me

James

##########
for b in O.bodies:
         if isinstance(b.shape,Sphere):
   if b.state.pos[2]>0 and b.state.pos[2]<cut*0.25:
    if b.state.pos[1]>0 and b.state.pos[1]<((ylength)*0.25):
     b.shape.color=(108, 51, 101)
    elif b.state.pos[1]>((ylength)*0.25) and b.state.pos[1]<((ylength)*0.5):
     b.shape.color=(72, 72, 147)

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-05-24
Last query:
2019-05-24
Last reply:
2019-05-23
Best Jan Stránský (honzik) said : #1

Hi James,
use values normalized to interval [0,1], e.g.

b.shape.color = (72/255.,72/255.,147/255.)

cheers
Jan

jamespaul (jamespauljames) said : #2

Thanks Jan Stránský, that solved my question.