question

Anna Lisa Dierking avatar image
1 Like"
Anna Lisa Dierking asked Joerg Vogel answered

Colors used with Color.ByNumber

Hi,

in the screenshot below you can see a Queue with 10,000 boxes in it. I used the Color.ByNumber(item.Number) function to color the boxes with item.number being a counter label.

Is there any reason why the color pattern looks like this with all the yellow and blue? Would it be possible to have more variety?

FlexSim 17.1.4
color changecolor palette
colorarray.png (638.5 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Matt Long avatar image
4 Likes"
Matt Long answered Jeff Nordgren edited

@Anna Lisa Dierking

This is actually a bug that was introduced with the new Color class. We'll get this fixed for the next bug fix release. It should look more like this:


colorbynumber.png (315.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Sam Stubbs avatar image
3 Likes"
Sam Stubbs answered Mischa Spelt commented

If you look at the Color.ByNumber entry in the User Manual it explains this phenomenon:

Returns a color by a uniquely identifying number.

  1. item.color = Color.byNumber(item.labelVal);

The number passed in refers to an index in the standard colors spectrum, as follows:

1 - red
2 - green
3 - blue
4 - yellow
5 - orange
6 - purple
7 - lime
8 - pink
9 - gray
10 - teal
11 - aqua
12 - brown
13 - light blue
14 - silver
15 - white
16 - gold

For numbers above 16, a unique color will generated based on an algorithm.

IF you want unique colors for each of your item types beyond 16, I'd recommend that something like assigning those colors/item Types in a GlobalTable, and then assign your items' Types and colors based on the table.

· 9
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered

Your own bynumber method consists of the approach to create a string array. The string contains the function to create a color out of its color components.

Each time you need a color of your colors you execute a string of the array.

Global variable array myColor

  1. Color(0.1, 0.0, 0.9)
  2.  
  3. Color(0.0, 0.0, 0.5)

Set a color by number of myColor

  1. item.color = executestring(myColor[1]);
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.