在 netlogo 中动态改变 rgb
change rgb dynamically in netlogo
所以我在 net logo 中写了一个简短的程序,我想根据它们拥有的变量 view
对我的海龟进行颜色编码,该变量在 -1 和 1 之间变化。我尝试使用 color-scale
在 netlogo 中定义颜色,但它并不完全符合我的要求。
我写这篇文章是为了描述我想要的,但是当我将 col
变量传递给 set color
命令时,netlogo 似乎变得混乱了。
to colorise;;------------------------------------------------------------
; this changes the agent's colour based on their current [view] score.
; We could use the color-scale in netlogo, but it only works for one colour
; and it's easy to end up with a colour so dark we can't see it against black patches.
moderate ; resets any agents which have somehow ended up with a view score outside -1 to +1
ifelse view > 0
[ let col ( 1 - view )
set col col * 255
set color [ 255 col col ]
]
[ let col ( 1 + view )
set col col * 255
set color [ col col 255 ]
]
end
有没有人有什么想法?
谢谢!
会
假设您已经正确限制了视图范围,您将 运行 陷入列表创建问题:您不能对变量使用括号表示法。而是尝试
set color (list col col 255)
等等
所以我在 net logo 中写了一个简短的程序,我想根据它们拥有的变量 view
对我的海龟进行颜色编码,该变量在 -1 和 1 之间变化。我尝试使用 color-scale
在 netlogo 中定义颜色,但它并不完全符合我的要求。
我写这篇文章是为了描述我想要的,但是当我将 col
变量传递给 set color
命令时,netlogo 似乎变得混乱了。
to colorise;;------------------------------------------------------------
; this changes the agent's colour based on their current [view] score.
; We could use the color-scale in netlogo, but it only works for one colour
; and it's easy to end up with a colour so dark we can't see it against black patches.
moderate ; resets any agents which have somehow ended up with a view score outside -1 to +1
ifelse view > 0
[ let col ( 1 - view )
set col col * 255
set color [ 255 col col ]
]
[ let col ( 1 + view )
set col col * 255
set color [ col col 255 ]
]
end
有没有人有什么想法?
谢谢!
会
假设您已经正确限制了视图范围,您将 运行 陷入列表创建问题:您不能对变量使用括号表示法。而是尝试
set color (list col col 255)
等等