![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
You can set state information in the graphics context, as well as get state information. For example, if you want to draw a heavy red line, rather than an ordinary black one, you easily can modify the example of Segment 671 by adding messages that change line width and change color.
To get line width, you send the lineWidth
message; to set line
width, you send the setLineWidth:
message with an integer argument.
To get line and text color, you send the foreColor
message; to set line and text color, you send the foreColor:
message
with a color namesuch as ClrRed
, ClrWhite
, or
ClrBlue
used as an index into the ColorConstants
pool dictionary established in Segment 672:
MeterGraphPane method definition instance drawMeter | thePen meterWidth xLft yBot | meterWidth := self width * 3 // 4. xLft := self width - meterWidth // 2. yBot := self height // 2. thePen := self pen. thePen setLineWidth: 5. thePen foreColor: ClrRed. thePen lineFrom: xLft @ yBot to: (xLft + meterWidth) @ yBot. thePen lineFrom: (xLft + (meterWidth // 2)) @ yBot to: (xLft + (meterWidth // 2)) @ (yBot - 10). thePen centerText: 'Untitled' at: ((self width) // 2) @ ((self height // 2) + (2 * thePen font height)).