Defining the pie wedge's geometry

Redefining baseContainsPt:


Defining the pie wedge's geometry

Notice that you can pick up the pie wedge by clicking anywhere within the imaginary circle from which the wedge was cut. The wedge inherits this behavior from circleMorph.

We need to redefine the method baseContainsPt:, which is the test used to define whether a point is within a morph.

 baseContainsPt: p = (| v. angle. |
	v: (p - center) xAxisReflect. "expect y to increase vertically"
	angle: v thetaDegrees.
	v r > radius ifTrue: [ ^false ].
	(angle >= startAngle) && [angle <= (startAngle + spanAngle)]
)
We need to transform from the display coordinate system (which has y increasing downwards) to the coordinate system we're using within wedges, which assumes y increases upwards; hence the xAxisReflect.

Once this method is entered, the morph can only be picked up by clicking in its visible area.

[ Previous ] [ Index ] [ Next ]