如何在 NetLogo 6.2 中为海龟制作颜色渐变?
How to make a color gradient for turtles in 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
。
所以在 turtle 过程中的任何地方,你可以:
set color scale-color yellow turtle-profiles-habitat (min ValidHabs) (max ValidHabs)
我正在尝试为海龟创建黄色渐变。我有 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
。
所以在 turtle 过程中的任何地方,你可以:
set color scale-color yellow turtle-profiles-habitat (min ValidHabs) (max ValidHabs)