Transparency Example
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This example demonstrates transparency in NetLogo.
HOW IT WORKS
Turtle, link, and label color values can contain lists of numbers which represent either RGB or RGBA colors, that is, red, green, and blue, or red, green, blue, and alpha. Alpha is used to represent how opaque or transparent a color is. Like red, green and blue values, range from 0 to 255 where 0 is completely transparent (invisible) and 255 is completely opaque (nothing behind it can be seen).
HOW TO USE IT
Press the SETUP button. Notice the clusters of turtles in the view.
Now press the SET-TRANSPARENCY button which will retain the current color of the turtles and add the transparency indicated in the slider. Take note of the clusters again.
Press:
inspect one-of turtles
to see a close up view of a smaller portion of the world.
THINGS TO NOTICE
At present transparency works only in the 2D view, not the 3D view.
Comments and Questions
to setup clear-all create-turtles 1000 [ setxy random-xcor random-ycor set color one-of [green blue] ] ;; make some clusters of turtles among the evenly distributed turtles as ;; it shows off the transparency better ask n-of 10 patches [ sprout 100 [ setxy (xcor + random-float 5) (ycor + random-float 5) set color green ] ] end to set-transparency ;; since turtle colors might be either numbers (NetLogo colors) or lists ;; (RGB or RGBA colors) make sure to handle both cases when changing the ;; transparency ifelse is-list? color ;; list might either have 3 or 4 member since RGB and RGBA colors ;; are allowed, so you can't just replace or add an item at the ;; end of the list. So, we take the first 3 elements of the list ;; and add the alpha to the end [ set color lput transparency sublist color 0 3 ] ;; to get the RGB equivalent of a NetLogo color we ;; use EXTRACT-RGB and then add alpha to the end [ set color lput transparency extract-rgb color ] end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 8 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Transparency Example.png | preview | Preview for 'Transparency Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.