Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | v e1 e2 e ctrlShape ctrls ctrl shape addBlock |
- v := RTView new.
- e1 := (RTEllipse new size: 30) elementOn: 'A'.
- e2 := (RTEllipse new size: 30) elementOn: 'B'.
- ctrlShape := RTEllipse new size: 10; color: (Color purple alpha: 0.3).
- "collection holding all control points INCLUDING starting & ending"
- ctrls := (ctrlShape elementsOn: (1 to: 2)).
- v
- add: e1;
- add: e2;
- addAll: ctrls.
- v elements @ RTDraggable.
- e := REEdge from: e1 to: e2.
- ctrls do: [ :el | el addConnectedEdge: e ].
- ctrls
- addFirst: e1;
- addLast: e2.
- ctrls @ (RTLabelled new text: [ :el | el ]).
- shape := RTMultiLine new color: Color blue.
- shape block: [ :fromPoint :toPoint |
- | points |
- points := ctrls collect: [ :el | el position ].
- points asArray.
- ].
- ctrls first translateBy: -50 @ 100.
- ctrls second translateBy: -50 @ 0.
- ctrls third translateBy: 50 @ 0.
- ctrls fourth translateBy: 50 @ 100.
- e + shape.
- v add: e.
- e trachelShape pushBack.
- v open.
- ctrls inspect.
- addBlock := [ :point |
- | index |
- "find between which control points are we adding a new one"
- index := (2 to: ctrls size) detect: [ :i |
- | fromPoint toPoint |
- fromPoint := (ctrls at: (i - 1)) position.
- toPoint := (ctrls at: i) position.
- point onLineFrom: fromPoint to: toPoint.
- ].
- ctrl := ctrlShape elementOn: 'X'.
- v add: ctrl.
- ctrl @ RTDraggable.
- ctrl addConnectedEdge: e.
- ctrl @ (RTLabelled new text: [:el | el ]).
- ctrl translateBy: point.
- ctrls add: ctrl beforeIndex: index.
- shape block: [ :fromPoint :toPoint |
- | points |
- points := ctrls collect: [ :el | el position ].
- points asArray.
- ].
- "reset all the things"
- v removeEdge: e.
- e resetShape.
- v add: e.
- e trachelShape pushBack.
- v signalUpdate.
- ].
- e when: TRMouseRightClick do: [ :event |
- addBlock value: event position.
- ].
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement