coloring

Asked by ytang

Hi all,

I want to set the color for my sample so that I can see the deformation by the colorful band, as shown in this paper[1].

here is the code for coloring
#####################
for b in O.bodies:
 if isinstance(b.shape,Sphere):
  if 0 < b.state.pos[2] <= 0.02:
   b.shape.color = (0.3,0,0.1)
  elif 0.02 < b.state.pos[2] <= 0.04:
   b.shape.color = (0.3,0.1,1)
  elif 0.04 < b.state.pos[2] <= 0.06:
   b.shape.color = (0.9,0.9,1)
###########################

 the reason why we can see the deformed colorful band after the sample was deformed is that the colored particles go to another place.

for my code, I set the particle color by the vertical height. since the vertical height doesn't change, so the colorful band will still be horizontal or not???
For example, if one particle in one region is black. when it goes into another region, will it change into another kind of color?
that is to say, if the color of one particle is set at the beginning, will it color changes when it goes into another region?

thanks in advance.
Yong

reference:
https://link.springer.com/article/10.1007/s11440-020-00951-7

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
Best Jan Stránský (honzik) said :
#1

> that is to say, if the color of one particle is set at the beginning, will it color changes when it goes into another region?

no, it remains the same.
It will change only when you explicitly change it

cheers
Jan

Revision history for this message
ytang (ytang116) said :
#2

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