-
Notifications
You must be signed in to change notification settings - Fork 91
pieWedgeMorph
Stephen De Gabrielle edited this page Mar 7, 2014
·
17 revisions
Make a pieWedgeMorph, taken from the Self 4.1 tutorial.
- `New shell`
- `circleMorph copy` `Get it`
- middle-click/menu-click
- pin the menu
- Add slot
percent <- 33.0 - Add slot
startAngle <- 0 - Add slot
amount <- 10 - `Show Morph` to show pie wedge morph. It is still a circle. Not a pie wedge. Yet.
- right-click/blue-menu the morph
- click `Move to Own Window` (If you have a separate window, messing up the draw method won’t crash the window you are developing in)
- Add slot baseDrawOn
baseDrawOn: canvas = (| r. | "X bug: zero span angle draws full circle!" percent = 0 ifTrue: [ ^self ]. "X bug: fillArc sometimes goes one pixel out of bounds" r: baseBounds indent: 1. canvas fillArcWithin: r From: startAngle Spanning: spanAngle Color: color. self ). - Add slot spanAngle
spanAngle = ( 3.6 * percent ). - Add slot
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)] ) - Add slot
morphTypeName = 'pieWedgeMorph'