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

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

Doit | Raw | Getting Started Workspace | Home | New
|v  tweet impact avatars profiles edge timeUnanswered container dummyData author  |


tweet := Tweet new.
tweet scrapDataFromUrl: 'https://twitter.com/offrayLC/status/599196718152949760'.
timeUnanswered := (Date today - tweet date) days.

dummyData := tweet impactFor: 'https://twitter.com/offrayLC/status/599196718152949760'.

"Impact box"
impact := RTBox new 
	color: (Color red);
	size: 200.
	
impact := impact element .
impact translateBy: (timeUnanswered*50)@0.

"The Tweet"

author := (TwitterProfile new scrapDataFromProfile: (tweet profile)) avatar. 
author := (RTBitmap new form: author) element.
author translateBy: (timeUnanswered*25)@(-600).


"Create profiles collecting information for all users mentioned in the tweet"
profiles := OrderedCollection new.
tweet mentions do: [:eachMention | 
	profiles add: (TwitterProfile new scrapDataFromProfile: eachMention)].

"Avatars
=========
Use the profiles to create a collection of avatar images which are draggable elements on a view"
avatars := OrderedCollection new.
profiles do: [:eachProfile |
	avatars add: (RTBitmap new form: eachProfile avatar) element ].
RTCircleLayout new
	initialRadius: (avatars size)*70;
	on: avatars.

container := (RTBox new color: Color transparent) element .
RTNest new on: container nest: avatars.

"Line"
edge := RTEdge from: container to: impact.

"Adding objects to the view, except avatars"
v := RTView new.
v add: impact.
v add: (edge + (RTGradientColoredLine new 
						colors: (Array with: (Color white alpha:0.3) with: (Color red alpha:0.9)); 
						precision: 100;
						width: 20; 
						gradientColorShape)).

"Adding labels"
edge @ (RTLabelled new text: [ :value | timeUnanswered asString, ' dias en silencio']; fontSize: timeUnanswered * 2.5; color: Color black ).

impact @ (RTLabelled new 
       text: (((dummyData at: 'retweeters') asString), 
				' Retweets');
       fontSize: timeUnanswered * 2;
		color: Color gray).

impact @ (RTLabelled new 
       text: (((dummyData at: 'reach') asString), 
				' seguidores');
       fontSize: timeUnanswered * 2;
		color: Color gray;
		 below).

"Adding avatars and its labels"
v addAll: avatars.
v add: container.

1 to: (avatars size) do: [:i |
(avatars at: i) @ (RTLabelled new 
       text: (('@',(tweet mentions at: i)));
		 fontSize: 35;
		 color: (Color black))].


v add: author.
author @ (RTLabelled new 
       text: ((tweet message text));
       fontSize: 35;
		color: Color black;
		 below;
		 offsetOnEdge: 1 ).

author @ (RTLabelled new 
       text: (('@',(tweet profile)));
       fontSize: 40;
		color: Color black ).


"Showing the canvas"

v view canvas focusOnCenterScaled.
v @ RTDraggableView.
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.