NetLogo/Teletortoise — pull request #78 by qiemem (2013-10-11 15:36:13+00:00)
Title: Too many different colors causes client to crash

Open `/wolfsheep` or something and throw in:

to setup
ca
crt 500
reset-ticks
end

to go
ask turtles [
fd 1
set color scale-color blue xcor min-pxcor max-pxcor
]
tick
end

Click go, and after 10 seconds or so, the page should crash. If you do it again and just check `Object.keys(session.controller.turtleView.drawer.shapeCache)`, you'll find an enormous array with many entries like:

"default,104.92367640184938"
"default,105.39265087337907"
"default,104.6981161679109"
"default,105.07632359815062"
"default,104.91001957826245"
"default,105.39975633080763"
"default,105.16269465723032"

The problem here is that in the shape cache, we use color as part of the key. So when we get floating point colors, bad things happen. The solution is to simply drop the fractional part (those don't affect color anyway). Note that rgb colors can have the same problem.