Skip to content

Instantly share code, notes, and snippets.

@progrium
Created October 23, 2011 12:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save progrium/1307282 to your computer and use it in GitHub Desktop.
Save progrium/1307282 to your computer and use it in GitHub Desktop.
RaphaelJS script to test badges
var badge = Raphael(200, 0, 225, 187);
// Header
var attrs = {'fill': '#f90', 'stroke': 'none', 'font-size': 11, 'font-family': 'helvetica'};
badge.rect(5, 3, 225, 14).attr(attrs);
badge.circle(212, 8, 16).attr(attrs);
var textAttrs = {'fill': '#fff', 'font-size': 11, 'font-family': 'helvetica', 'text-anchor': 'end'};
var text = badge.text(198, 9, "SuperHappyDevHouse");
text.attr(textAttrs);
var num = badge.text(211, 9, "48");
num.attr(textAttrs);
num.attr({'font-size': 18, 'text-anchor': 'middle', 'font-weight': 'bold'});
post(function(canvas) {
canvas.image("http://img268.imageshack.us/img268/378/superhappydevhouse.png", -1, -2, 30, 26);
});
// Name
if ($('#first_name').val()) {
var firstName = badge.text(0, 50, $('#first_name').val());
firstName.attr({'font-size': 65, 'font-family': 'helvetica', 'text-anchor': 'start', 'font-weight': 'bold'});
fitWidth(firstName, 224);
}
if ($('#last_name').val()) {
var lastName = badge.text(5, 94, $('#last_name').val());
lastName.attr({'font-size': 28, 'font-family': 'helvetica', 'text-anchor': 'start'});
fitWidth(lastName, 224);
}
// Tags
if ($('#tags').val()) {
var tags = badge.text(112, 130, $('#tags').val());
tags.attr({'font-size': 24, 'font-family': 'helvetica', 'text-anchor': 'middle'});
fitWidth(tags, 220);
}
// Footer / Sponsor
var link = badge.text(0, 168, "j.mp/shdh-test");
link.attr({'font-size': 20, 'font-weight': 'bold', 'font-family': 'courier', 'fill': '#999', 'text-anchor': 'start'});
fitWidth(link, 185);
post(function(canvas) {
canvas.image("http://a2.twimg.com/profile_images/953764608/tech_logo_bigger.jpg", 195, 157, 28, 28);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment