home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1997-02-06 | 9.4 KB | 244 lines | [TEXT/3PRM] |
- definition module deltaPicture;
-
-
- // Version 0.8 to 1.0
-
- //
- // Drawing functions and other operations on Pictures.
- //
-
- import deltaFont;
-
- /*
- :: *Picture;
-
- :: DrawFunction -> => Picture Picture;
-
- == Predefined figures:
-
- :: Point -> (!INT, !INT);
- :: Line -> (!Point, !Point);
- :: Curve -> (!Oval, !INT, !INT);
- :: Rectangle -> (!Point, !Point);
- :: RoundRectangle -> (!Rectangle, !INT, !INT);
- :: Oval -> Rectangle;
- :: Circle -> (!Point, !INT);
- :: Wedge -> (!Oval, !INT, !INT);
- :: Polygon -> (!Point, !PolygonShape);
-
- :: PolygonShape -> [Vector];
- :: Vector -> (!INT, !INT);
-
- == The pen attributes which influence the way figures are drawn:
-
- :: PenSize -> (!INT, !INT);
- :: PenMode -> CopyMode | OrMode | XorMode |
- ClearMode | HiliteMode | NotCopyMode |
- NotOrMode | NotXorMode | NotClearMode;
- :: PenPattern -> BlackPattern | DkGreyPattern | GreyPattern |
- LtGreyPattern | WhitePattern;
-
- == The predefined colours:
-
- :: Colour -> RGB REAL REAL REAL
- | BlackColour | RedColour
- | WhiteColour | GreenColour
- | BlueColour | YellowColour
- | CyanColour | MagentaColour;
-
- MACRO
- MinRGB -> 0.0;
- MaxRGB -> 1.0;
-
- RULE
-
- << Rules setting the attributes of a Picture:
- >>
-
- << SetPenSize (w, h) sets the PenSize to w pixels wide and h pixels high.
- SetPenMode sets the drawing mode of the pen.
- SetPenPattern sets the pattern of the pen.
- SetPenNormal sets the SetPenSize to (1,1), the PenMode to CopyMode and
- the PenPattern to BlackPattern. >>
-
- :: SetPenSize !PenSize !Picture -> Picture;
- :: SetPenMode !PenMode !Picture -> Picture;
- :: SetPenPattern !PenPattern !Picture -> Picture;
- :: SetPenNormal !Picture -> Picture;
-
- << Colour: There are two types of Colours: RGB colours and basic colours.
- An RGB colour defines the amount of red (r), green (g) and blue (b)
- in a certain colour by the tuple (r,g,b). These are REAL values and
- each of them must be between MinRGB and MaxRGB (0.0 and 1.0).
- The colour black is defined by (MinRGB, MinRGB, MinRGB) and white
- by (MaxRGB, MaxRGB, MaxRGB). Given a RGB colour, all amounts are
- adjusted between MinRGB and MaxRGB.
- Only FullColour windows can apply RGB colours. Applications that use
- these windows may not run on all computers (e.g. Macintosh Plus).
- A small set of basic colours is defined that can be used on all systems.
- SetPenColour sets the colour of the pen.
- SetBackColour sets the background colour. >>
-
- :: SetPenColour !Colour !Picture -> Picture;
- :: SetBackColour !Colour !Picture -> Picture;
-
- << Fonts: The initial font of a Picture is the DefaultFont (See
- deltaFont.dcl). On the Macintosh the default font is
- plain 12 points Geneva.
- SetFont sets a new complete Font in the Picture.
- SetFontName sets a new font without changing the style or size.
- SetFontStyle sets a new style without changing font or size. An
- empty list of FontStyle gives the plain style.
- SetFontSize sets a new size without changing font or style.
- The size is always adjusted between MinFontSize and
- MaxFontSize (see deltaFont.dcl). >>
-
- :: SetFont !Font !Picture -> Picture;
- :: SetFontName !FontName !Picture -> Picture;
- :: SetFontStyle ![FontStyle] !Picture -> Picture;
- :: SetFontSize !FontSize !Picture -> Picture;
-
- << PictureCharWidth (PictureStringWidth) yield the width of the given
- CHAR (STRING) given the current font of the Picture.
- PictureFontMetrics yields the FontInfo of the current font. >>
-
- :: PictureCharWidth !CHAR !Picture -> (!INT, !Picture);
- :: PictureStringWidth !STRING !Picture -> (!INT, !Picture);
- :: PictureFontMetrics !Picture -> (!FontInfo, !Picture);
-
- << Rules changing the position of the pen:
- >>
-
- << Absolute and relative pen move operations (without drawing). >>
-
- :: MovePenTo !Point !Picture -> Picture;
- :: MovePen !Vector !Picture -> Picture;
-
- << Absolute and relative pen move operations (with drawing). >>
-
- :: LinePenTo !Point !Picture -> Picture;
- :: LinePen !Vector !Picture -> Picture;
-
- << DrawChar (DrawString) draws the character (string) in the current font.
- The baseline of the characters is the y coordinate of the pen.
- The new position of the pen is directly after the (last) character
- (of the string). >>
-
- :: DrawChar !CHAR !Picture -> Picture;
- :: DrawString !STRING !Picture -> Picture;
-
- << Rules that don't change the position of the pen after drawing:
- >>
-
- << Draw(C)Point draws a pixel (in the given colour) in the Picture.
- Draw(C)Line draws a line (in the given colour) in the Picture.
- Draw(C)Curve draws a curve (in the given colour) in the Picture.
- A Curve is part of an Oval o starting from angle a upto
- angle b (both of type INT in degrees modulo 360): (o, a, b).
- See Wedges for further information on the angles. >>
-
- :: DrawPoint !Point !Picture -> Picture;
- :: DrawLine !Line !Picture -> Picture;
- :: DrawCurve !Curve !Picture -> Picture;
- :: DrawCPoint !Point !Colour !Picture -> Picture;
- :: DrawCLine !Line !Colour !Picture -> Picture;
- :: DrawCCurve !Curve !Colour !Picture -> Picture;
-
- << A Rectangle is defined by two diagonal corner Points.
- DrawRectangle draws the edges of the rectangle.
- FillRectangle draws the edges and interior of the rectangle.
- EraseRectangle erases the edges and interior of the rectangle.
- InvertRectangle inverts the edges and interior of the rectangle.
- MoveRectangleTo moves the contents of the rectangle to a new top corner.
- MoveRectangle moves the contents of the rectangle over the given vector.
- CopyRectangleTo copies the contents of the rectangle to a new top corner.
- CopyRectangle copies the contents of the rectangle over the given vector. >>
-
- :: DrawRectangle !Rectangle !Picture -> Picture;
- :: FillRectangle !Rectangle !Picture -> Picture;
- :: EraseRectangle !Rectangle !Picture -> Picture;
- :: InvertRectangle !Rectangle !Picture -> Picture;
- :: MoveRectangleTo !Rectangle !Point !Picture -> Picture;
- :: MoveRectangle !Rectangle !Vector !Picture -> Picture;
- :: CopyRectangleTo !Rectangle !Point !Picture -> Picture;
- :: CopyRectangle !Rectangle !Vector !Picture -> Picture;
-
- << Rounded corner rectangles: a RoundRectangle with enclosing Rectangle
- r and corner curvatures x and y is defined by the tuple (r, x, y).
- x and y define the horizontal and vertical diameter of the corner curves.
- They are adjusted between 0 and the width (height) of r. >>
-
- :: DrawRoundRectangle !RoundRectangle !Picture -> Picture;
- :: FillRoundRectangle !RoundRectangle !Picture -> Picture;
- :: EraseRoundRectangle !RoundRectangle !Picture -> Picture;
- :: InvertRoundRectangle !RoundRectangle !Picture -> Picture;
-
- << Ovals: an Oval is defined by its enclosing Rectangle.
- Note : the Oval of a square Rectangle is a Circle. >>
-
- :: DrawOval !Oval !Picture -> Picture;
- :: FillOval !Oval !Picture -> Picture;
- :: EraseOval !Oval !Picture -> Picture;
- :: InvertOval !Oval !Picture -> Picture;
-
- << Circles: a Circle with center c (Point) and radius r (INT) is
- defined by the tuple (c, r). >>
-
- :: DrawCircle !Circle !Picture -> Picture;
- :: FillCircle !Circle !Picture -> Picture;
- :: EraseCircle !Circle !Picture -> Picture;
- :: InvertCircle !Circle !Picture -> Picture;
-
- << Wedges: a Wedge is a pie-part of an Oval o starting from angle a
- upto angle b (both of type INT in degrees modulo 360): (o, a, b).
- Angles are always taken counterclockwise, starting from 3 o'clock. >>
-
- :: DrawWedge !Wedge !Picture -> Picture;
- :: FillWedge !Wedge !Picture -> Picture;
- :: EraseWedge !Wedge !Picture -> Picture;
- :: InvertWedge !Wedge !Picture -> Picture;
-
- << A Polygon is a number of consecutive points between which lines are drawn.
- The starting point of the Polygon is also the end point. The PolygonShape
- is a list of vectors that defines the shape of the Polygon.
- ScalePolygon scales (reduces, enlarges) the Polygon. Non-postive scale
- factors are allowed.
- MovePolygonTo changes the starting point into the given Point.
- MovePolygon moves the starting point by the given Vector. >>
-
- :: ScalePolygon !INT !Polygon -> Polygon;
- :: MovePolygonTo !Point !Polygon -> Polygon;
- :: MovePolygon !Vector !Polygon -> Polygon;
- :: DrawPolygon !Polygon !Picture -> Picture;
- :: FillPolygon !Polygon !Picture -> Picture;
- :: ErasePolygon !Polygon !Picture -> Picture;
- :: InvertPolygon !Polygon !Picture -> Picture;
- */
-
- from Picture import
- Picture, DrawFunction,
- Point, Line, Curve, Rectangle, RoundRectangle,
- Oval, Circle, Wedge, Polygon, PolygonShape, Vector,
- PenSize,
- PenMode,
- CopyMode, OrMode, XorMode, ClearMode, HiliteMode,
- NotCopyMode, NotOrMode, NotXorMode, NotClearMode,
- PenPattern, BlackPattern, DkGreyPattern, GreyPattern, LtGreyPattern, WhitePattern,
- Colour, RGB, MinRGB, MaxRGB,
- BlackColour, RedColour, WhiteColour, GreenColour,
- BlueColour, YellowColour, CyanColour, MagentaColour,
- SetPenSize, SetPenMode, SetPenPattern, SetPenNormal, SetPenColour, SetBackColour,
- SetFont,SetFontName, SetFontStyle, SetFontSize,
- PictureCharWidth, PictureStringWidth, PictureFontMetrics,
- MovePenTo, MovePen, LinePenTo, LinePen,
- DrawChar, DrawString,
- DrawPoint, DrawLine, DrawCurve, DrawCPoint, DrawCLine, DrawCCurve,
- CopyRectangleTo, CopyRectangle, MoveRectangleTo, MoveRectangle,
- DrawRectangle, FillRectangle, EraseRectangle, InvertRectangle,
- DrawRoundRectangle, FillRoundRectangle, EraseRoundRectangle, InvertRoundRectangle,
- DrawOval, FillOval, EraseOval, InvertOval,
- DrawCircle, FillCircle, EraseCircle, InvertCircle,
- DrawWedge, FillWedge, EraseWedge, InvertWedge,
- DrawPolygon, FillPolygon, ErasePolygon, InvertPolygon,
- ScalePolygon, MovePolygonTo, MovePolygon;
-