unit User; {This module is the place to put user additions to Image. You will need } {to uncomment the call to InitUser in Image.p.} interface uses QuickDraw, OSIntf, PickerIntf, PrintTraps, ToolIntf, globals, Utilities, Graphics; procedure InitUser; procedure DoUserCommand1; procedure DoUserCommand2; procedure DoUserMenuEvent (MenuItem: integer); implementation {User global variables go here.} procedure InitUser; begin UserMenuH := GetMenu(UserMenu); InsertMenu(UserMenuH, 0); DrawMenuBar; {Additional user initialization code goes here.} end; procedure DrawDot (row, column, RowOffset, ColumnOffset: integer; big: boolean); var h, v: integer; begin if big then begin for h := -1 to 1 do for v := -1 to 1 do PutPixel(column * 16 + ColumnOffset * 4 + h + 16, row * 16 + RowOffset * 4 + v + 16, BlackIndex) end else PutPixel(column * 16 + ColumnOffset * 4 + 16, row * 16 + RowOffset * 4 + 16, BlackIndex); end; procedure DrawNeighborhood (i, row, column: integer); begin DrawDot(row, column, 0, 0, BitAnd(i, 1) = 1); DrawDot(row, column, 0, 1, BitAnd(i, 2) = 2); DrawDot(row, column, 0, 2, BitAnd(i, 4) = 4); DrawDot(row, column, 1, 2, BitAnd(i, 8) = 8); DrawDot(row, column, 2, 2, BitAnd(i, 16) = 16); DrawDot(row, column, 2, 1, BitAnd(i, 32) = 32); DrawDot(row, column, 2, 0, BitAnd(i, 64) = 64); DrawDot(row, column, 1, 0, BitAnd(i, 128) = 128); DrawDot(row, column, 1, 1, true); end; procedure DoUserCommand1; {Generates a table showing all possible 3x3 neighborhoods. This table is used} { for making up the "fate table" used by the Skeletonize command and the Wand tool.} var row, column, index: integer; begin row := 0; column := 0; if NewPicWindow('Fate Table', 600, 200) then for index := 0 to 255 do begin DrawNeighborhood(index, row, column); column := column + 1; if column = 32 then begin row := row + 1; column := 0; end; end; end; procedure DoUserCommand2; begin beep; end; procedure DoUserMenuEvent (MenuItem: integer); begin case MenuItem of 1: DoUserCommand1; 2: DoUserCommand1; end; end; end.