Shared Smalltalk Workspace http://ws.stfx.eu/

http://ws.stfx.eu/http://ws.stfx.eu/

Doit | Raw | Getting Started Workspace | Home | New
"Idea: calcular el centro de masa de varios RTBox"
| view impact avatars edge cm centro timeUnanswered |

view := RTView new.

timeUnanswered := 28.

avatars := OrderedCollection new.
1 to: 10 do: [:eachProfile |
	avatars add: (RTBox new width: 150; height: 150) element @ RTDraggable ].

"Adding avatars and putting them in proper layout"
avatars do: [:avatar | view add: avatar].
RTCircleLayout new
	initialRadius: 150;
	on: avatars.
	
"Impact"
impact := RTBox new 
	color: (Color red alpha: 0.3);
	size: 200.
	
impact := impact element @ RTDraggable.
impact translateBy: (timeUnanswered*50)@0.
view add: impact.
	
"Computing center of mass"
cm := (0@0).
avatars do: [ :avatar | cm := cm + ((avatar position)/(avatars size )) ].
centro := RTBox new width: 2; height: 2.
centro := centro element.
edge := RTEdge from: centro to: impact.
view add: edge.
centro translateBy: cm.
view add: centro.
view add: (edge + (RTGradientColoredLine new 
						colors: (Array with: (Color white alpha:0.3) with: (Color red alpha:0.9)); 
						precision: 100;
						width: 7; 
						gradientColorShape)).
view view canvas focusOnCenterScaled .
THIS SOFTWARE SERVICE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR SERVICE PROVIDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE SERVICE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE SERVICE.