5.7.GRAPHICSMODULEREFERENCE 81
TextMethods
Text(anchorPoint, string)Constructsa textobjectthatdisplaysthegivenstringcenteredat
anchorPoint. Thetextis displayedhorizontally.
setText(string)Setsthetextoftheobjecttostring.
getText()Returnsthecurrentstring.
getAnchor()Returnsa cloneoftheanchorpoint.
setFace(family)Changesthefontfacetothegivenfamily. Possiblevaluesare:’helvetica’,
’courier’,’timesroman’, and’arial’.
setSize(point)Changesthefontsizetothegivenpointsize.Sizesfrom5 to 36 pointsarelegal.
setStyle(style) Changesfonttothegivenstyle. Possiblevaluesare: ’normal’,’bold’,
’italic’, and’bolditalic’.
5.7.3 EntryObjects.
ObjectsoftypeEntryaredisplayedastext entryboxesthatcanbeeditedbytheuseroftheprogram.Entry
objectssupportthegenericgraphicsmethodsmove(),draw(graphwin),undraw(),setFill(color),
andclone(). TheEntryspecificmethodsaregivenbelow.
Entry(centerPoint,width)ConstructsanEntryhavingthegivencenterandwidth. Thewidth
is specifiedinnumberofcharactersoftextthatcanbedisplayed.
getAnchor()Returnsa cloneofthepointwheretheentryboxis centered.
getText()Returnsthestringoftextthatis currentlyintheentrybox.
setText(string)Setsthetextintheentryboxtothegivenstring.
5.7.4 DisplayingImages
Thegraphicsmodulealsoprovidesminimalsupportfordisplayingcertainimageformatsintoa GraphWin.
MostplatformswillsupportJPEG,PPMandGIFimages.Displayis donewithanImageobject.Images
supportthegenericmethodsmove(dx,dy),draw(graphwin),undraw(), andclone(). Image
specificmethodsaregivenbelow.
Image(centerPoint,filename)Constructsanimagefromcontentsofthegivenfile,centeredat
thegivencenterpoint.
getAnchor()Returnsa cloneofthepointwheretheimageis centered.
5.7.5 GeneratingColors
Colorsareindicatedbystrings.Mostnormalcolorssuchas’red’,’purple’,’green’,’cyan’, etc.
shouldbeavailable.Many colorscomeinvariousshades,suchas’red1’,’red2’,’red3’,’red4’,
whichareincreasinglydarkershadesofred.
Thegraphicsmodulealsoprovidesa functionformixingyourowncolorsnumerically. Thefunction
colorrgb(red, green, blue)willreturna stringrepresentinga colorthatis a mixtureoftheinten-
sitiesofred,greenandbluespecified.Theseshouldbeintsin therange0–255.Thuscolorrgb(255, 0, 0)
is a brightred,whilecolorrgb(130, 0, 130)is a mediummagenta.