From 4d9ed26ccc7294cb4bfa8eb9c6d0ec4f5fae9605 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Wed, 22 Oct 2008 19:04:45 -0700 Subject: [PATCH] Added AvatarSize option. Not too useful now, we need more general scaling --- src/AvatarFetcher.java | 2 ++ src/FreebaseAvatarFetcher.java | 6 +++++- src/GravatarFetcher.java | 2 +- src/code_swarm.java | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/AvatarFetcher.java b/src/AvatarFetcher.java index 37e5244..4c1db92 100644 --- a/src/AvatarFetcher.java +++ b/src/AvatarFetcher.java @@ -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) { diff --git a/src/FreebaseAvatarFetcher.java b/src/FreebaseAvatarFetcher.java index 8afcbaf..53eb9e3 100644 --- a/src/FreebaseAvatarFetcher.java +++ b/src/FreebaseAvatarFetcher.java @@ -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; diff --git a/src/GravatarFetcher.java b/src/GravatarFetcher.java index 5906095..5b90830 100644 --- a/src/GravatarFetcher.java +++ b/src/GravatarFetcher.java @@ -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; diff --git a/src/code_swarm.java b/src/code_swarm.java index 2624f4b..fdc8749 100644 --- a/src/code_swarm.java +++ b/src/code_swarm.java @@ -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)); } } }