Shape Library Viewer
Model was written in NetLogo 6.4.0
•
Viewed 167 times
•
Downloaded 18 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
GLOBALS [ SAMPLE# VARI-COLOR BACKGROUND BCOLOR BCOLOR2 VCOLOR BRIGHTNESS CHECKERED? TRANS? OPACITY ZOOM GALLERY-ROW-SIZE GALLERY-COUNT GALLERY-X GALLERY-Y OLD-PAGE PAGE-NUMBER PAGES-COUNT TITLE-PATCH PAGE-LABEL-PATCH COLOR-LABEL-PATCH SORT-SHAPES PIXEL ANIMATE-START ANIMATE-END ANIMATE-FPS ANIMATE-FRAME BACK1 BACK2 BIG-SAMPLE NETLOGO-SHAPES NETLOGO-LIBRARY-SHAPES ] BREED [ SAMPLES SAMPLE ] BREED [ BACKDROPS BACKDROP ] BREED [ PREVIEWS PREVIEW ] BREED [ HALOS HALO ] SAMPLES-OWN [ MY-HALO IDX ] HALOS-OWN [ MY-SAMPLE ] TO-REPORT UPPERCASE [ STRING ] SET STRING (WORD STRING) ;; CHARACTERS IN APPROX ENGLISH USAGE FREQUENCY ORDER LET UPP "ETAOINSHRDLCUMWFGYPBVKJXQZ" LET LOW "etaoinshrdlcumwfgypbvkjxqz" FOREACH RANGE LENGTH STRING [ I -> LET N POSITION (ITEM I STRING) LOW IF N != FALSE [ SET STRING REPLACE-ITEM I STRING (ITEM N UPP) ] ] REPORT STRING END TO-REPORT LOWERCASE [ STRING ] SET STRING (WORD STRING) ;; CHARACTERS IN APPROX ENGLISH USAGE FREQUENCY ORDER LET UPP "ETAOINSHRDLCUMWFGYPBVKJXQZ" LET LOW "etaoinshrdlcumwfgypbvkjxqz" FOREACH RANGE LENGTH STRING [ I -> LET N POSITION (ITEM I STRING) UPP IF N != FALSE [ SET STRING REPLACE-ITEM I STRING (ITEM N LOW) ] ] REPORT STRING END TO SETUP-WORLD SET GALLERY-ROW-SIZE 10 SET GALLERY-COUNT GALLERY-ROW-SIZE * GALLERY-ROW-SIZE RESIZE-WORLD 0 (GALLERY-ROW-SIZE * 4 - 1) 0 (GALLERY-ROW-SIZE * 2) + 3 SET-PATCH-SIZE 25 SET PIXEL (1 / PATCH-SIZE) SET GALLERY-X MAX-PXCOR - (2 * GALLERY-ROW-SIZE) + 1 SET GALLERY-Y MAX-PYCOR - 3 END TO SETUP-GLOBALS SET SORT-SHAPES MAP LOWERCASE SORT SHAPES SET NETLOGO-SHAPES GET-NETLOGO-SHAPES SET NETLOGO-LIBRARY-SHAPES GET-NETLOGO-LIBRARY-SHAPES SET PAGES-COUNT 1 + INT (LENGTH SHAPES / GALLERY-COUNT) SET VARI-COLOR GRAY SET BACKGROUND BLACK SET CHECKERED? TRUE SET TRANS? FALSE SET OPACITY 0 SET BRIGHTNESS 20 SET ZOOM 100 SET SAMPLE# 0 SET ANIMATE-START 0 SET ANIMATE-END 0 SET ANIMATE-FPS 4 SET ANIMATE-FRAME 0 SET BIG-SAMPLE NOBODY SET GALLERY-X MIN-PXCOR + WORLD-WIDTH / 2 SET GALLERY-Y MAX-PYCOR - 3 SET TITLE-PATCH PATCH (MIN-PXCOR) (MAX-PYCOR) SET PAGE-LABEL-PATCH PATCH (GALLERY-X - 2) (MAX-PYCOR) SET COLOR-LABEL-PATCH PATCH (MIN-PXCOR + 1) (MIN-PYCOR + 3) END TO SET-PAGE [ N ] SET OLD-PAGE PAGE-NUMBER SET PAGE-NUMBER MIN (LIST PAGES-COUNT MAX (LIST 0 N) ) SET SAMPLE# PAGE-NUMBER * GALLERY-COUNT ASK SAMPLES [ SET HEADING 0 ] SET-TEXT PAGE-LABEL-PATCH (WORD "PAGE " (PAGE-NUMBER + 1)" OF " PAGES-COUNT " - " LENGTH SHAPES " SHAPES") SHOW-PREVIEW SAMPLE# END TO SHOW-PREVIEW [ N ] SET SAMPLE# N MOD LENGTH SHAPES LET NEW-PAGE INT (SAMPLE# / GALLERY-COUNT) IF NEW-PAGE != PAGE-NUMBER [ SET-PAGE NEW-PAGE STOP ] LET PREVIEW-SIZE (MIN LIST WORLD-WIDTH WORLD-HEIGHT) - 6 IF NOT ANY? BACKDROPS [ CREATE-BACKDROPS 1 [ HOME SET HEADING 0 SET SIZE PREVIEW-SIZE LET CX MIN-PXCOR - .5 + SIZE / 2 + 1 LET CY MIN-PYCOR - .5 + (WORLD-HEIGHT / 2) SETXY CX CY SET BACK1 SELF HATCH-BACKDROPS 1 [ SET BACK2 SELF ] HATCH-PREVIEWS 1 [ SET BIG-SAMPLE SELF ] ] ] SET ZOOM MAX (LIST 5 MIN (LIST 200 ZOOM)) SET BACKGROUND BACKGROUND MOD 15 SET VARI-COLOR VARI-COLOR MOD 17 SET VCOLOR 0 ( IFELSE ( VARI-COLOR = 0 ) [ SET VCOLOR BLACK ] ( VARI-COLOR = 1 ) [ SET VCOLOR GRAY ] ( VARI-COLOR = 2 ) [ SET VCOLOR WHITE ] [ SET VCOLOR 15 + 10 * ( VARI-COLOR - 2 ) ] ) IF ( TRANS? ) [ SET OPACITY 1 + ( ( OPACITY - 1 ) MOD 9 ) SET VCOLOR LPUT INT ( 25.5 * OPACITY ) EXTRACT-RGB VCOLOR ] SET BRIGHTNESS BRIGHTNESS MOD 100 SET BCOLOR SCALE-COLOR ( 5 + 10 * BACKGROUND ) BRIGHTNESS 0 100 SET BCOLOR2 BCOLOR IF ( CHECKERED? ) [ SET BCOLOR BLACK ] SET-TEXT COLOR-LABEL-PATCH ( WORD "\n" "COLOR: " VCOLOR ", PCOLOR: " BCOLOR2 ", ZOOM: " ZOOM "%" ) ASK BACK1 [ SET SHAPE "SQUARE" SET COLOR BCOLOR ] ASK BACK2 [ SET SHAPE "CHECKS SMALL" SET COLOR BCOLOR2 ] ASK BIG-SAMPLE [ SET SIZE PREVIEW-SIZE * ( ZOOM / 100 ) SET SHAPE ITEM SAMPLE# SORT-SHAPES SET COLOR VCOLOR SET-TEXT TITLE-PATCH ( WORD "NETLOGO SHAPE LIBRARY VIEWER -- \"" SHAPE "\"") ] DISPLAY-SAMPLES END TO SETUP-SAMPLES LET OFFSET COUNT TURTLES ;; WITHOUT-INTERRUPTION ;; [ CREATE-SAMPLES GALLERY-COUNT [ SET IDX WHO - OFFSET LET X GALLERY-X + 2 * (IDX MOD GALLERY-ROW-SIZE) LET Y GALLERY-Y - 2 * INT (IDX / GALLERY-ROW-SIZE) SET SHAPE "SQUARE" SET HEADING 0 SET COLOR PCOLOR + 1 SET SIZE 40 * PIXEL SETXY X Y ;; SHOW (WORD "X: " X " Y: " Y ) ;; ] ASK SAMPLES [ HATCH-HALOS 1 [ SET SHAPE "BLANK" SET COLOR WHITE SET SIZE 48 * PIXEL SET MY-SAMPLE MYSELF ASK MYSELF [ SET MY-HALO MYSELF ] HIDE-TURTLE ] ] ] SET OLD-PAGE -1 END TO DISPLAY-SAMPLES IF NOT ANY? SAMPLES [ SETUP-SAMPLES ] IF OLD-PAGE != PAGE-NUMBER [ ;; UPDATE SHAPE IMAGES SET OLD-PAGE PAGE-NUMBER ASK SAMPLES [ LET SHAPE-NUM PAGE-NUMBER * GALLERY-COUNT + IDX ;; HIDE SAMPLE IF NO SHAPE (SAMPLE# IS BEYOND SHAPE LIST) ;; SHOW SHAPE-NUM IFELSE SHAPE-NUM >= LENGTH SHAPES [ SET SHAPE "BLANK" SET COLOR PCOLOR + 1 HIDE-TURTLE ASK MY-HALO [ SET SHAPE "BLANK" SET COLOR WHITE HIDE-TURTLE ] ] [ ;; ASSIGN SHAPE SET SHAPE ITEM SHAPE-NUM SORT-SHAPES SHOW-TURTLE ] ] ] ;; UPDATE COLORS AND HALOS ASK SAMPLES [ SET COLOR VCOLOR LET NEW-HALO "BLANK" (IFELSE (SHAPE = [ SHAPE ] OF BIG-SAMPLE) [ SET NEW-HALO "SQUARE OPEN THICK" ] ( MEMBER? SHAPE NETLOGO-LIBRARY-SHAPES) [ SET NEW-HALO "SQUARE OPEN THIN" ] [] ) ASK MY-HALO [ SET SHAPE NEW-HALO SET COLOR WHITE SET HIDDEN? SHAPE = "BLANK" ] ] END TO SET-TEXT [ LOCATION TEXT ] LET JOIN [STRINGS -> WORD "\n" (REDUCE [ [ A B ] -> ( WORD A "\na" B ) ] ( SENTENCE STRINGS ) ) ] ASK LOCATION [ SET PLABEL ( RUN-RESULT JOIN TEXT ) ] END TO-REPORT TRIANGLE-WAVE [ X ] REPORT 2 * ABS( 2 * ( X - FLOOR( X + 0.5 ) ) ) - 1 END TO-REPORT SAWTOOTH-WAVE [ X ] REPORT 2 * ( X - 0.5 - FLOOR X ) END TO-REPORT SQUARE-WAVE [ X ] REPORT 2 * (2 * (FLOOR X) - (FLOOR (2 * X)) ) + 1 END TO-REPORT SINE-WAVE [ X ] REPORT SIN (X * 360 ) END TO-REPORT DC [ X ] REPORT (1 + X) / 2 END TO ANIMATE SET ANIMATE-FPS FPS LET FRAME 1 + ANIMATE-END - ANIMATE-START IF FRAME = 0 [ SET FRAME 1 ] LET T (TIMER / FRAME * ANIMATE-FPS) IFELSE BOUNCE [ SET ANIMATE-FRAME FRAME * DC TRIANGLE-WAVE T ] [ SET ANIMATE-FRAME FRAME * DC SAWTOOTH-WAVE T ] SET ANIMATE-FRAME MIN LIST FRAME MAX LIST 0 ANIMATE-FRAME ASK BIG-SAMPLE [ SET SHAPE ITEM (ANIMATE-START + ANIMATE-FRAME) SORT-SHAPES ] END TO-REPORT GET-NETLOGO-SHAPES REPORT MAP LOWERCASE (LIST "AIRPLANE" "ARROW" "BOX" "BUG" "BUTTERFLY" "CAR" "CIRCLE" "CIRCLE 2" "COW" "CYLINDER" "DOT" "FACE HAPPY" "FACE NEUTRAL" "FACE SAD" "FISH" "FLAG" "FLOWER" "HOUSE" "LEAF" "LINE" "LINE HALF" "PENTAGON" "PERSON" "PLANT" "SHEEP" "SQUARE" "SQUARE 2" "STAR" "TARGET" "TREE" "TRIANGLE" "TRIANGLE 2" "TRUCK" "TURTLE" "WHEEL" "WOLF" "X") END TO-REPORT GET-NETLOGO-LIBRARY-SHAPES REPORT MAP LOWERCASE (LIST ; 567890123456789=123456789012345678901234567890123456789012345678901234567890 "ACORN" "AIRPLANE 2" "AMBULANCE" "ANT" "ANT 2" "APPLE" "ARROW 2" "ARROW 3" "BALL BASEBALL" "BALL BASKETBALL" "BALL FOOTBALL" "BALL TENNIS" "BALLOON" "BALLPIN" "BANANA" "BEE" "BEE 2" "BIKE" "BIRD" "BIRD 2" "BIRD 3" "BIRD SIDE" "BOAT" "BOAT 2" "BOAT 3" "BOAT TOP" "BOOK" "BOTTLE" "BOWLING PIN" "BOX" "BOX 2" "BREAD" "BUILDING INSTITUTION" "BUILDING STORE" "BULLDOZER TOP" "BUS" "BUTTERFLY 2" "CACTUS" "CAMPSITE" "CANNON" "CANNON CARRIAGE" "CAR SIDE" "CAR TOP" "CAT" "CATERPILLAR" "CHECK" "CHECKER PIECE" "CHECKER PIECE 2" "CHESS BISHOP" "CHESS KING" "CHESS KNIGHT" "CHESS PAWN" "CHESS QUEEN" "CHESS ROOK" "CLOCK" "CLOUD" "COIN HEADS" "COIN TAILS" "COMPUTER SERVER" "COMPUTER WORKSTATION" "CONTAINER" "COW SKULL" "CRATE" "CROWN" "DART" "DIE 1" "DIE 2" "DIE 3" "DIE 4" "DIE 5" "DIE 6" "DOG" "DOLLAR BILL" "DROP" "EGG" "ELECTRIC OUTLET" "EMBLEM" "EXCLAMATION" "EYEBALL" "FACTORY" "FIRE" "FIRE DEPARTMENT" "FISH 2" "FISH 3" "FLOWER BUDDING" "FOOD" "FOOTPRINT HUMAN" "FOOTPRINT OTHER" "FROG TOP" "GARBAGE CAN" "GHOST" "HAWK" "HEX" "HEXAGONAL PRISM" "HOUSE BUNGALOW" "HOUSE COLONIAL" "HOUSE EFFICIENCY" "HOUSE RANCH" "HOUSE TWO STORY" "I BEAM" "KEY" "LANDER" "LANDER 2" "LEAF 2" "LETTER OPENED" "LETTER SEALED" "LIGHTNING" "LILY PAD" "LINK" "LOGS" "MAGNET" "MAMMOTH" "MOLECULE HYDROGEN" "MOLECULE OXYGEN" "MOLECULE WATER" "MONSTER" "MOON" "MOOSE" "MOOSE-FACE" "MORTAR PESTLE" "MOUSE SIDE" "MOUSE TOP" "MUSIC NOTES 1" "MUSIC NOTES 2" "MUSIC NOTES 3" "ORBIT 1" "ORBIT 2" "ORBIT 3" "ORBIT 4" "ORBIT 5" "ORBIT 6" "PAINTBRUSH" "PENCIL" "PERSON BUSINESS" "PERSON CONSTRUCTION" "PERSON DOCTOR" "PERSON FARMER" "PERSON GRADUATE" "PERSON LUMBERJACK" "PERSON POLICE" "PERSON SERVICE" "PERSON SOLDIER" "PERSON STUDENT" "PETALS" "PLANT MEDIUM" "PLANT SMALL" "POLICE" "PUMPKIN" "PUSHPIN" "RABBIT" "ROCKET" "SAILBOAT SIDE" "SHARK" "SHEEP 2" "SPIDER" "SPINNER" "SQUIRREL" "STRAWBERRY" "SUIT CLUB" "SUIT DIAMOND" "SUIT HEART" "SUIT SPADE" "SUN" "TANK" "TELEPHONE" "TILE BRICK" "TILE LOG" "TILE STONES" "TILE WATER" "TOOTH" "TRAIN" "TRAIN FREIGHT BOXCAR" "TRAIN FREIGHT ENGINE" "TRAIN FREIGHT HOPPER EMPTY" "TRAIN FREIGHT HOPPER FULL" "TRAIN PASSENGER CAR" "TRAIN PASSENGER ENGINE" "TRAIN SWITCHER ENGINE" "TREE PINE" "TRUCK CAB ONLY" "TRUCK CAB TOP" "TURTLE 2" "UFO SIDE" "UFO TOP" "VAN SIDE" "VAN TOP" "WARNING" "WOLF 2" "WOLF 3" "WOLF 4" "WOLF 5" "WOLF 6" "WOLF 7" ) END TO _SETUP CA SETUP-WORLD SETUP-GLOBALS SET-TEXT TITLE-PATCH "NETLOGO SHAPE LIBRARY VIEWER" SET-PAGE 0 ;; SETUP-SAMPLES SHOW-PREVIEW 0 END TO STARTUP _SETUP END TO SETUP STARTUP END TO GO END
There are 9 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Shape Library Viewer.png | preview | Preview for 'Shape Library Viewer' | about 1 year ago, by James Steiner | Download |
This model does not have any ancestors.
This model does not have any descendants.