home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 5.8 KB | 175 lines | [TEXT/ToyS] |
- property kasGenTitle : "Generating Icon"
-
-
- on run
- ShowAlert("Drop items on this Applet to give them random icons.")
- end run
-
-
- on open fsObjs
- -- Get our icon
- set myIcon to (the icon for (path to me))
-
- repeat with fsObj in fsObjs
- set inf to basic info for fsObj
- if (catalog kind of inf) is a folder then
- if (folder ref of inf is 2) then -- root directory?
- set ic to GenerateVolumeIcon()
- else
- set ic to GenerateFolderIcon()
- end if
- else
- set ic to GenerateItemIcon()
- end if
- -- Is it a server item?
- if (vol kind of (the volume info of fsObj) is AFP volume) then
- set choice to (display dialog ¬
- ("The item " & (catalog name of (basic info for fsObj)) & " is on a server volume." & ¬
- return & return & ¬
- "Do you want to set compatible icons?") buttons {"< 8.5", "> 8.1", "Both"} default button 3)
- set the icon of fsObj to ic compatibility (button returned of choice is "Both")
- else
- set the icon of fsObj to ic
- end if
- end repeat
- end open
-
-
- -- All in 128 x 128 with pen 4x4
- property kasVolPolyT : {{108, 12}, {0, 12}, {16, 0}, {124, 0}, {108, 12}}
- property kasVolPolyR : {{108, 12}, {108, 124}, {124, 108}, {124, 0}, {108, 12}}
- property kasVolPoly : {{108, 12}, {0, 12}, {0, 124}, {108, 124}, {108, 12}}
-
- property kasColMin : 22222
- property kasColMax : 61116
- property kasColStepMin : 11
- property kasColStepMax : 111
- property kasCentMin : 8
- property kasCentMax : 100
-
-
- on GenerateVolumeIcon()
- set icWin to ¬
- display drawing titled kasGenTitle ¬
- with dimensions {128, 128}
-
- -- Draw solids
- draw a polygon into icWin ¬
- using data kasVolPolyT ¬
- using state {fg color:"CCCCCC"} ¬
- filling it with the pen
- draw a polygon into icWin ¬
- using data kasVolPolyR ¬
- using state {fg color:"BBBBBB"} ¬
- filling it with the pen
- draw a polygon into icWin ¬
- using data kasVolPoly ¬
- using state {fg color:"EEEEEE"} ¬
- filling it with the pen
-
- -- Draw Face
- set cx to random number from kasCentMin to kasCentMax
- set cy to 16 + (random number from kasCentMin to kasCentMax)
- set cr to random number from kasColMin to kasColMax
- set cg to random number from kasColMin to kasColMax
- set cb to random number from kasColMin to kasColMax
- set sr to random number from kasColStepMin to kasColStepMax
- set sg to random number from kasColStepMin to kasColStepMax
- set sb to random number from kasColStepMin to kasColStepMax
-
- -- Top Roll
- repeat with x from 4 to 108
- draw a line into icWin ¬
- inside of {x, 16, cx, cy} ¬
- using state {fg col64:{cr, cg, cb}, pen size:{1, 1}}
-
- set cr to cr + sr
- set cg to cg + sg
- set cb to cb + sb
-
- if (cr > kasColMax) then set sr to -(random number from kasColStepMin to kasColStepMax)
- if (cr < kasColMin) then set sr to (random number from kasColStepMin to kasColStepMax)
- if (cg > kasColMax) then set sg to -(random number from kasColStepMin to kasColStepMax)
- if (cg < kasColMin) then set sg to (random number from kasColStepMin to kasColStepMax)
- if (cb > kasColMax) then set sb to -(random number from kasColStepMin to kasColStepMax)
- if (cb < kasColMin) then set sb to (random number from kasColStepMin to kasColStepMax)
- end repeat
-
- -- Right Roll
- repeat with y from 16 to 124
- draw a line into icWin ¬
- inside of {107, y, cx, cy} ¬
- using state {fg col64:{cr, cg, cb}, pen size:{1, 1}}
-
- set cr to cr + sr
- set cg to cg + sg
- set cb to cb + sb
-
- if (cr > kasColMax) then set sr to -(random number from kasColStepMin to kasColStepMax)
- if (cr < kasColMin) then set sr to (random number from kasColStepMin to kasColStepMax)
- if (cg > kasColMax) then set sg to -(random number from kasColStepMin to kasColStepMax)
- if (cg < kasColMin) then set sg to (random number from kasColStepMin to kasColStepMax)
- if (cb > kasColMax) then set sb to -(random number from kasColStepMin to kasColStepMax)
- if (cb < kasColMin) then set sb to (random number from kasColStepMin to kasColStepMax)
- end repeat
-
- -- Bottom Roll
- repeat with x from 108 to 4 by -1
- draw a line into icWin ¬
- inside of {x, 123, cx, cy} ¬
- using state {fg col64:{cr, cg, cb}, pen size:{1, 1}}
-
- set cr to cr + sr
- set cg to cg + sg
- set cb to cb + sb
-
- if (cr > kasColMax) then set sr to -(random number from kasColStepMin to kasColStepMax)
- if (cr < kasColMin) then set sr to (random number from kasColStepMin to kasColStepMax)
- if (cg > kasColMax) then set sg to -(random number from kasColStepMin to kasColStepMax)
- if (cg < kasColMin) then set sg to (random number from kasColStepMin to kasColStepMax)
- if (cb > kasColMax) then set sb to -(random number from kasColStepMin to kasColStepMax)
- if (cb < kasColMin) then set sb to (random number from kasColStepMin to kasColStepMax)
- end repeat
-
- -- Left Roll
- repeat with y from 124 to 16 by -1
- draw a line into icWin ¬
- inside of {4, y, cx, cy} ¬
- using state {fg col64:{cr, cg, cb}, pen size:{1, 1}}
-
- set cr to cr + sr
- set cg to cg + sg
- set cb to cb + sb
-
- if (cr > kasColMax) then set sr to -(random number from kasColStepMin to kasColStepMax)
- if (cr < kasColMin) then set sr to (random number from kasColStepMin to kasColStepMax)
- if (cg > kasColMax) then set sg to -(random number from kasColStepMin to kasColStepMax)
- if (cg < kasColMin) then set sg to (random number from kasColStepMin to kasColStepMax)
- if (cb > kasColMax) then set sb to -(random number from kasColStepMin to kasColStepMax)
- if (cb < kasColMin) then set sb to (random number from kasColStepMin to kasColStepMax)
- end repeat
-
- -- Draw frame
- draw a polygon into icWin ¬
- using data (kasVolPoly & kasVolPolyT & kasVolPolyR) ¬
- using state {fg color:"111111", pen size:{4, 4}}
-
- set ic to ¬
- capture picture from icWin ¬
- using depth 32 ¬
- with pixel conversion
- display drawing icWin with disposal
-
- return ic
- end GenerateVolumeIcon
-
-
- on GenerateItemIcon()
- return GenerateVolumeIcon()
- end GenerateItemIcon
-
-
- on GenerateFolderIcon()
- return GenerateVolumeIcon()
- end GenerateFolderIcon
-