如何在NetLogo 6.2中为海龟制作颜色渐变



我正试图为海龟创建一个黄色渐变。我有31只乌龟的简介,我希望每只乌龟都是黄色的。我正在尝试更多,剩下的都是白色的。我认为我正在使代码复杂化,结果不会出来。有人做过类似的事情吗?如果是的话,你能提出一个方法吗?

globals [ AvailablePatch UnassignedProfileCountList ValidHabs MidpointnlColor2 TotalShades2 ]

turtles-own [ turtle-profiles-habitat ]
patches-own [ turtle-count habitatcover ]
to setup
clear-all    
set ValidHabs [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ] 

set UnassignedProfileCountList [ 0 ] 
repeat 31
[
set UnassignedProfileCountList lput 9 UnassignedProfileCountList
]


(    
foreach ValidHabs [      
this-profile ->      

set MidpointnlColor2 yellow
set TotalShades2 2


ask one-of AvailablePatch
[
sprout 1

[
set turtle-profiles-habitat this-profile


set color make-nl-color-shade2 MidpointnlColor2 ValidHabs TotalShades2            

set size 1
]
set turtle-count count turtles-here
set AvailablePatch other AvailablePatch            
]
]
)
end

to-report make-nl-color-shade2 [ nl-color shade-value num-shades ]  
set shade-value min list num-shades max list 0 shade-value
report scale-color nl-color shade-value num-shades 0 
end

您可以使用scale-color color number range1 range2对颜色进行着色。如果要基于ValidHabs缩放,则需要范围从ValidHabs的最小值(min ValidHabs(到最大值(max ValidHabs(。对于每只乌龟,你都希望有它们真正的栖息地,即turtle-profiles-habitat

所以在海龟手术的任何地方,你都可以:

set color scale-color yellow turtle-profiles-habitat (min ValidHabs) (max ValidHabs)

相关内容

  • 没有找到相关文章

最新更新