# HG changeset patch # User Robert McIntyre # Date 1280231782 14400 # Node ID 9649b14f3b3853c08110ec6da9303f3a9514fc5a # Parent 388344355ebfc4243d127f53b76b70c3ea76d39d made main drawing function capable of rendering style selection boxes. no more pics needed diff -r 388344355ebf -r 9649b14f3b38 buy3.html --- a/buy3.html Tue Jul 27 05:14:22 2010 -0400 +++ b/buy3.html Tue Jul 27 07:56:22 2010 -0400 @@ -14,6 +14,9 @@
+
+
+
diff -r 388344355ebf -r 9649b14f3b38 css/buy3.css --- a/css/buy3.css Tue Jul 27 05:14:22 2010 -0400 +++ b/css/buy3.css Tue Jul 27 07:56:22 2010 -0400 @@ -9,6 +9,7 @@ font: bold 15px "helvetica","arial", "sans-serif"; color: white; height: 200px; + display : none; } div#text-entry { diff -r 388344355ebf -r 9649b14f3b38 js-lib/buy3.js --- a/js-lib/buy3.js Tue Jul 27 05:14:22 2010 -0400 +++ b/js-lib/buy3.js Tue Jul 27 07:56:22 2010 -0400 @@ -3,16 +3,32 @@ //Cards drawing functions: - var Cards = - {"bold" : { - "name" :(function (text, display){ - return display.print(10,20,text,helvetica, 25).attr( - {"fill" : "#0F0"});}), - "email" : (function (text, paper){ - return paper.print(50,50,text,helvetica_I,40).attr( - {"fill" : "red"});})} + var magic_font_ratio = 318; //the font size for identity under .scale(1,1) + var mfg = magic_font_ratio; + + + var draw_card = (function (paper){ + + var helvetica = paper.getFont('HelveticaNeue', 700); + var helveticaI = paper.getFont('HelveticaNeue', 800); + var h = paper.height; + var w = paper.width; + + return { + "bold" : { + "name" :(function (text){ + return paper.print(w*0.1,h*0.2,text,helvetica).attr( + {"fill" : "#0F0"}).scale(0.0002*h,0.00025*w,w*0.1,h*0.2);}), + "email" : (function (text){ + return paper.print(w*0.1,h*0.4,text,helveticaI).attr( + {"fill" : "red"}).scale(0.0002*h,0.00025*w,w*0.1,h*0.4);})} }; + + }); + + + @@ -74,7 +90,8 @@ var helvetica_I; var state_map = { - bold : {ref : null}, + bold : null, + classic : null, green : {ref : null, offState : {"fill" : "#030", "scale": 1} , @@ -108,7 +125,8 @@ var display_init = (function (){ state_map["display"].ref = - display.rect(1, 1, 338, 213, 20).attr(state_map["display"].state); + display.rect(1, 1 , display.width - 1, display.height - 2, 20).attr( + state_map["display"].state); }); var text_entry_init = (function (){ @@ -124,20 +142,26 @@ if ($(this).val() == $(this).attr('title')){ $(this).val('');}})})}); - + var style_text = { + phone : "617.821.9129", + email : "rlm@mit.edu", + website : "www.rlmcintyre.com", + name : "Robert McIntyre", + company : "LaserKard LLC.", + occupation : "AI Researcher"} var style_init = (function (){ - state_map["bold"] = style.bold.set(); - //var yyy = Cards.bold.name("Ru", style.bold); - - //for each (var item in yyy.items) {item.scale(0.5, 0.5);} -// for (var letter in yyy) { -// letter.scale(0.5,0.5);} - - state_map["bold"].push(Cards.bold.name("Robert", style.bold)); - state_map["bold"].attr({"fill" : "red"}); //.scale(0.5, 0.5, 0, 0); - state_map["bold"].scale(0.03, 0.03, 0 , 0); + var draw = draw_card(style.bold); + draw.bold.name(style_text.name); + style.bold.rect(1, 1 ,style.bold.width - 1, style.bold.height - 2, 10); + draw.bold.email(style_text.email); + // state_map["bold"] = style.bold.set(); + // state_map["bold"].push(Cards.bold.name(style_text.name, style.bold)); + // state_map["bold"].push(Cards.bold.email(style_text.email, style.bold)); + // + // state_map["bold"].attr({"fill" : "red"}); + // state_map["bold"].scale(0.03, 0.03, 0 , 0); }); @@ -147,8 +171,11 @@ var init = (function () { display = Raphael("card-display", 340 ,215); color = Raphael("color-select", 300, 100); - style.bold = Raphael("bold", 100, 100); - //style = Raphael("style-select", 200, 70); + + style.bold = Raphael("bold", 170, 107); + + style.classic = Raphael("classic", 170 , 107); + helvetica = display.getFont('HelveticaNeue', 700); helvetica_I = display.getFont('HelveticaNeue', 800); color_select_init(); @@ -213,10 +240,12 @@ var display_style_update = (function (){ var style = null; + return (function () { + var draw = draw_card(display); if (style !== order.style){ for ( var property in card ){ - if (!Cards[order.style][(deref(property))]){ + if (!draw[order.style][(deref(property))]){ $("#user" + "-" + property).toggle(400);}} style = order.style;} });})(); @@ -229,12 +258,13 @@ company : "nothing", website : "nothing" }; - var check_text = (function (var_name) { + var check_text = (function (var_name) { + var draw = draw_card(display); if (state[deref(var_name)] !== (card[deref(var_name)]).text){ - if (Cards[order.style][deref(var_name)]) { + if (draw[order.style][deref(var_name)]) { card[deref(var_name)].ref.remove(); card[var_name].ref = - Cards[order.style][deref(var_name)]( + draw[order.style][deref(var_name)]( card[deref(var_name)].text,display); state[deref(var_name)] = card[deref(var_name)].text; }}});