Transparency Example

Transparency Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 420 times • Downloaded 44 times • Run 0 times
Download the 'Transparency Example' modelDownload this modelEmbed this model

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.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version

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.