module Draw; from Layers import all; export all; object ColorPalette is components:cl:Color*, pc:PrimaryColor, sc:SecondaryColor; operations:SetPrimary, SetSecondary; description:(* ColorPalette is used for the drawing tools. *); end ColorPalette; object PrimaryColor is components: col:Color; description:(* Primary Color is the color used when using the left mouse button. *); end PrimaryColor; object SecondaryColor is components: col:Color; description:(* Secondary Color is the color used when using the left mouse button. *); end SecondaryColor; operation SetPrimary is inputs:cp:ColorPalette, c:Color; outputs:cp':ColorPalette; precondition: (*The list of colors must contain c*) c in cp.cl; postcondition: (*The primary color is changed*) cp'.pc = c; description:(* This operation sets the primary color to the given color. *); end SetPrimary; operation SetSecondary is inputs:cp:ColorPalette, c:Color; outputs:cp':ColorPalette; precondition: (*The list of colors must contain c*) c in cp.cl; postcondition: (*The primary color is changed*) cp'.sc = c; description:(* This operation sets the secondary color to the given color. *); end SetSecondary; object CurrentTool is Tool description:(* Drawing tools are used to edit a layer. *); end CurrentTool; object Tool is components:X1, Y1, X2, Y2, Color; description:(* A tool has a start, finish and color. *); end Tool; object X1 is components:XCoordinate; description:(* X1 is an address on the x axis of a layer. *); end X1; object X2 is components:XCoordinate; description:(* X2 is an address on the x axis of a layer. *); end X2; object Y1 is components:YCoordinate; description:(* Y1 is an address on the y axis of a layer. *); end Y1; object Y2 is components:YCoordinate; description:(* Y2 is an address on the y axis of a layer. *); end Y2; object Ellipse inherits from Tool description:(* An ellipse is a circular object. *); end Ellipse; object Rectangle inherits from Tool description:(* An rectangle is a square object. *); end Rectangle; object TextBox inherits from Tool components:string; description:(* A textbox is a rectangle with text in it. *); end TextBox; object Line inherits from Tool description:(* A line has a start and finish point. *); end Line; object Eraser inherits from Tool components:XCoordinate*, YCoordinate*; description:(* An eraser has a set of coordinates and a fixed radius. *); end Eraser; object Pencil inherits from Tool components:XCoordinate*, YCoordinate*; description:(* An eraser has a set of coordinates. *); end Eraser; object StudentStickyNote inherits from Tool components:TextBox; description:(* X1 and Y1 determine the placement of the textbox which is expandable and colapsable. *); end StudentStickyNote; object Fill inherits from Tool description:(* X1 and Y1 determine the area that will be filled. *); end Fill; object Curve inherits from Tool components: X3, Y3; description:(* A curve has a start point, a finish point, and a curve point. *); end Curve; object X3 is components:XCoordinate; description:(* X3 is an address on the x axis of a layer. *); end X3; object Y3 is components:YCoordinate; description:(* Y3 is an address on the y axis of a layer. *); end Y3; operation Magnefy inputs:l:Layer; outputs:l':Layer; precondition: (*none*); postcondition: (*The Layer is magnefied.*); description:(* This operation zooms in on the given Layer. *); end Magnefy; operation Draw is inputs:l:Layer, t:Tool; outputs:l':Layer; precondition: (*none*); postcondition: (*The tool is transfered onto the layer*); description:(* This operation places a tool on the current layer. *); end Draw; end Draw;