Yuval Levy
Yuval Levy

Reputation: 2516

circle inside a square in Smalltalk

I draw a circle inside a square in Smalltalk But I want to reduce it size by 10% so i tried to write it like that:

initialize
 | circleWidth circleHeight|
  super initialize.
  self label: ''.
  self borderWidth: 0.
  bounds := 0@0 corner: 70@70.

  circle := CircleMorph new.
  circleWidth := self bounds width*0.9.
  circleHeight := self bounds height*0.9.
  circle bounds: self bounds*0.9.

  circle color: Color paleBuff.
  circle borderWidth: 1.
  self addMorphCentered: circle.


  offColor := Color gray darker.
  onColor := Color gray darker.
  self useSquareCorners.
  self turnOff

But the line: circle bounds: self bounds*0.9. has some problem when compiling "Message not understood rectangle >>*" how can I do it?

Upvotes: 0

Views: 341

Answers (1)

MartinW
MartinW

Reputation: 5041

Use the message scaleBy: scale to scale a rectangle.

So

circle bounds: self bounds*0.9.

becomes:

circle bounds: (self bounds scaleBy: 0.9).

Upvotes: 2

Related Questions