Transparency Example
Model was written in NetLogo 5.0.4
•
Viewed 429 times
•
Downloaded 45 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
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 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.