Halo Example

Halo Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner over 12 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 826 times • Downloaded 148 times • Run 1 time
Download the 'Halo 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.)


WHAT IS IT?

This example shows how to give a turtle a "halo", to make it stand out. The halo travels with the turtle.

The same technique might be useful in other ways as well. For example, you might use it to show the radius a turtle can sense things in.

Also, in this example, the halo is a circle, but you could use any shape you can draw in the shapes editor. You could vary the size, color, and shape of the halos however you want, to make many different kinds of indicators.

THINGS TO NOTICE

Note that the watch command has a somewhat similar effect visually: it puts a "spotlight" on a turtle. But using the spotlight as an indicator is limited. You can only have one spotlight. You can't control the color of the spotlight. The size of the spotlight is determined by the size of the turtle being watched, and isn't otherwise adjustable. So if the spotlight isn't flexible enough for your needs, you may want to use the technique shown in this code example instead.

One thing the spotlight does that the technique in this code example can't do is darken everything outside the spotlight.

EXTENDING THE MODEL

Improve the buttons in the Interface tab that create and destroy halos to include sanity/safety checks. The button that creates halos shouldn't put a halo on a turtle that already has one; the button that destroys halos shouldn't blow up if there are no halos left.

NETLOGO FEATURES

Note the use of the tie primitive.

Note the use of an RGB color with an alpha value to make partially transparent halos.

RELATED MODELS

Label Position Example

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [runners runner]
breed [halos halo]

to setup
  clear-all
  ;; the "thin ring" shape was made using the shapes editor;
  ;; it's a simple, unfilled circle
  set-default-shape halos "thin ring"
  create-runners 250
    [ setxy random-xcor random-ycor ]
  reset-ticks
end 

to go
  ask runners [ fd 0.1 ]
  tick
end 

to make-halo  ;; runner procedure
  ;; when you use HATCH, the new turtle inherits the
  ;; characteristics of the parent.  so the halo will
  ;; be the same color as the turtle it encircles (unless
  ;; you add code to change it
  hatch-halos 1
  [ set size 5
    ;; Use an RGB color to make halo three fourths transparent
    set color lput 64 extract-rgb color
    ;; set thickness of halo to half a patch
    __set-line-thickness 0.5
    ;; We create an invisible directed link from the runner
    ;; to the halo.  Using tie means that whenever the
    ;; runner moves, the halo moves with it.
    create-link-from myself
    [ tie
      hide-link ] ]
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 10 versions of this model.

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

Attached files

File Type Description Last updated
Halo Example.png preview Preview for 'Halo Example' over 12 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.