property pLineSize -- the thickness of the lines drawn property pFilled -- are the squares filled, or not? property pRedValue -- red color value of the grid property pGreenValue -- green color value of the grid property pBlueValue -- blue color value of the grid property pStartingPoint -- the starting x,y drawing point for the grid property pNumColumns -- the number of columns to draw property pNumRows -- the number of rows to draw property pRectWidth -- the width of each grid box property pRectHeight -- the height of each grid box property pXspacing -- the X-axis spacing of the grid property pYspacing -- the Y-axis spacing of the grid ----------------------------------------------------------- -- This behavior draws a user-specified grid on the stage -- using imaging Lingo. Place this in a frame script. -- No other sprites are needed for it to work. -- Ken Loge - http://diginoodles.com ----------------------------------------------------------- on getPropertyDescriptionList me list = [:] addProp list, #pStartingPoint, [#comment: "Grid draw starting point:", #format: #point, #default: point(0,0)] addProp list, #pFilled, [#comment: "Grid rectangles are filled:", #format: #boolean, #default: FALSE] addProp list, #pLineSize, [#comment: "Line thickness:", #format: #integer, #default: 1, #range: [#min: 1, #max: 30]] addProp list, #pRedValue, [#comment: "Red color value of the grid:", #format: #integer, #default: 0, #range: [#min: 0, #max: 255]] addProp list, #pGreenValue, [#comment: "Green color value of the grid:", #format: #integer, #default: 0, #range: [#min: 0, #max: 255]] addProp list, #pBlueValue, [#comment: "Blue color value of the grid:", #format: #integer, #default: 0, #range: [#min: 0, #max: 255]] addProp list, #pNumColumns, [#comment: "Number of columns in the grid:", #format: #integer, #default: 20, #range: [#min: 1, #max: 100]] addProp list, #pNumRows, [#comment: "Number of rows in the grid:", #format: #integer, #default: 15, #range: [#min: 1, #max: 100]] addProp list, #pRectWidth, [#comment: "Width of each grid box:", #format: #integer, #default: 30, #range: [#min: 1, #max: 100]] addProp list, #pRectHeight, [#comment: "Height of each grid box:", #format: #integer, #default: 30, #range: [#min: 1, #max: 100]] addProp list, #pXspacing, [#comment: "X-axis spacing of each grid box:", #format: #integer, #default: -1, #range: [#min: -100, #max: 100]] addProp list, #pYspacing, [#comment: "Y-axis spacing of each grid box:", #format: #integer, #default: -1, #range: [#min: -100, #max: 100]] return list end on exitFrame me _movie.go(_movie.frame) end on mouseUp me drawGrid(me) end -- use imaging Lingo to draw a grid on the stage on drawGrid me -- get an image of the stage myImage = _movie.stage.image -- adjusted width and height of each grid cell -- cellWidth = pStartingPoint.locH + pRectWidth + pXspacing -- cellHeight = pStartingPoint.locV + pRectHeight + pYspacing cellWidth = pRectWidth + pXspacing cellHeight = pRectHeight + pYspacing -- draw rows and columns repeat with cols = 1 to pNumColumns x1 = (cellWidth * cols) - (-pStartingPoint.locH + pRectWidth) x2 = x1 + pRectWidth repeat with rows = 1 to pNumRows y1 = (cellHeight * rows) - (-pStartingPoint.locV + pRectHeight) y2 = y1 + pRectHeight -- handle filled or hollow shapes if pFilled then -- filled myImage.fill(point(x1, y1), point(x2, y2), [#shapeType: #rect, #lineSize: pLineSize, #color: rgb(pRedValue, pGreenValue, pBlueValue)]) else -- hollow myImage.draw(point(x1, y1), point(x2, y2), [#shapeType: #rect, #lineSize: pLineSize, #color: rgb(pRedValue, pGreenValue, pBlueValue)]) end if end repeat end repeat end