Skip to content

Commit

Permalink
Added AvatarSize option. Not too useful now, we need more general sca…
Browse files Browse the repository at this point in the history
…ling
  • Loading branch information
rictic committed Oct 23, 2008
1 parent 506fe07 commit 4d9ed26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/AvatarFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

public class AvatarFetcher {
protected CodeSwarmConfig cfg;
public int size;
public AvatarFetcher(CodeSwarmConfig cfg) {
this.cfg = cfg;
size = cfg.getPositiveIntProperty("AvatarSize", 40);
}

public String fetchUserImage(String username) {
Expand Down
6 changes: 5 additions & 1 deletion src/FreebaseAvatarFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public String fetchUserImage(String username) {
try {
String imageID = getUserImageID(username);
if (imageID == null) return null;
return getImage(key, new URL("http://www.freebase.com/api/trans/image_thumb/" +imageID+ "?maxheight=40&mode=fillcrop&maxwidth=40"));
return getImage(key, new URL("http://www.freebase.com/api/trans/image_thumb/"
+ imageID
+ "?maxheight=" + size
+ "&maxwidth=" + size
+ "&mode=fillcrop"));
} catch (MalformedURLException e) {
e.printStackTrace(); //should be impossible...
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/GravatarFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public GravatarFetcher(CodeSwarmConfig cfg) {
public String fetchUserImage(String username) {
String hash = md5Hex(username);
try {
return getImage(hash, new URL("http://www.gravatar.com/avatar/" + hash + "?d=identicon&s=40"));
return getImage(hash, new URL("http://www.gravatar.com/avatar/" + hash + "?d=identicon&s=" + size));
} catch (MalformedURLException e) {
e.printStackTrace(); //should be impossible...
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/code_swarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ public void draw() {
if (icon != null){
colorMode(RGB);
tint(255,255,255,max(0,life-80));
image(icon, mPosition.x-20, mPosition.y-35);
image(icon, mPosition.x-(avatarFetcher.size / 2), mPosition.y-(avatarFetcher.size - 5));
}
}
}
Expand Down

0 comments on commit 4d9ed26

Please sign in to comment.