Home Segments Index Top Previous Next

624: Mainline

The Rectangle class also has width and height methods, which answer with number instances representing the width and height of the rectangle, and a center method, which answers with a point instance representing the center of the rectangle. The center coordinates are rounded to the nearest integer:

Workspace
Transcript 
  show: (Rectangle origin: 16@10 extent: 5@3) height printString; cr; 
  show: (Rectangle origin: 16@10 extent: 5@3) width printString; cr; 
  show: (Rectangle origin: 16@10 extent: 5@3) center printString; cr 
Transcript 
3 
5 
18 @ 11