Permalink
Browse files

Fix tweets and bounds

  • Loading branch information...
1 parent 3e82cf3 commit 2578dcd8177b8efbf3d27f23a6f8c1142ce1c6ca @gigasquid committed Jul 14, 2012
Showing with 6 additions and 11 deletions.
  1. +6 −11 roomba.js
View
@@ -19,6 +19,7 @@ getTweets();
//Width and height
var w = 500;
var h = 500;
+var roomba_image = 48;
var svg = d3.select("body").append("svg").attr("width", w).attr("height", h);
//setup the room
@@ -27,37 +28,33 @@ svg.append("rect").attr("width", w).attr("height", h).attr("fill", "#ffffee")
//setup the tweet area
d3.select("body").append("div").attr("class", "tweet");
-
-
var roomba = svg.selectAll("roomba").data(roomba_data).enter()
.append("g")
.append("svg:image")
.attr("class", "roomba")
.attr("xlink:href", "roomba.gif")
- .attr("width", 48)
- .attr("height", 48)
+ .attr("width", roomba_image)
+ .attr("height", roomba_image)
.attr("x", function(d) { return d[0];})
.attr("y", function(d) { return d[1];});
var tweet = svg.selectAll("g")
.append("text");
function next_position(){
- return Math.floor(Math.random() * 460) + 20;
+ return Math.floor(Math.random() * (490 - roomba_image) + (roomba_image + 10));
}
function showTweet(){
- var i = tweet_num;
if (tweets.length > tweet_num +1){
tweet_num++;
}
- if (tweets.length < tweet_num +1){
+ if (tweets.length <= tweet_num +1){
tweet_num = 0;
}
d3.select(".tweet").text(tweets[tweet_num]);
}
-
function move(){
var new_x = next_position();
var new_y = next_position();
@@ -67,9 +64,7 @@ function move(){
showTweet();
- setTimeout(move, 2000 + 200);
+ setTimeout(move, 4000 + 200);
}
move();
-
-

0 comments on commit 2578dcd

Please sign in to comment.