$(document).ready(function(){ app.c.init(); app.v.init(); app.c.listeners(); }) ///////////////////////////////////////////////////////////////////////////////// var app={m:{},v:{},c:{}}; ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// app.c.init=function(){ app.m.password=false; app.m.metadata={"name":"Iconic","version":"0.0.2"}; var b=app.c.bounds(); app.m.genome={}; app.m.genome.r=[]; app.m.genome.rf=[]; app.m.genome.color=[]; app.m.genome.lw=[]; app.m.genome.steps=[]; app.m.genome.incrementMod=[]; app.m.genome.n=[]; app.m.genome.rotation=[]; app.m.genome.fadeColor=[]; app.m.genome.fadeRadius=[]; }; app.c.listeners=function(){ $("#mitLicense").on("click",function(){ $("#license").slideToggle(); }); $("input#clear").on("click",function(){ $("div#icons").html(""); for (var i=0;i<5;i++){ var iconWidth=$("input[name=size]:checked").val(); iconWidth=parseInt(iconWidth); app.v.icon("div#icons",iconWidth); //console.log(iconWidth); } }); /* $(window).resize(function(){ $("body").fadeOut(function(){ $("body").html(""); app.c.init(); app.v.init(); $("body").fadeIn(); }) }); */ }; app.c.bounds=function(){ var b=app.m.bounds={}; b.left=0; b.top=0; b.right=$(document).width(); b.bottom=$(document).height(); b.centerX=b.right/2; b.centerY=b.bottom/2; return b; }; ///////////////////////////////////////////////////////////////////////////////// app.v.init=function(){ app.v.style(); var b=app.m.bounds; var d=""; d+=""; d+="
"; d+=""; d+=""; d+=""; d+=""; d+=""; d+="

1024

512

144

72
"; d+="
"; d+="
"; d+="
"; d+=""; d+="
"; d+="

click the icons you save below for a png version

" d+="
"; d+=davis.license(); $("body").html(d); var iconWidth=$("input[name=size]:checked").val(); iconWidth=parseInt(iconWidth); //console.log(iconWidth); for (var i=0;i<5;i++){ app.v.icon("div#icons",iconWidth); } }; app.v.icon=function(target,width){ app.m.text=$("input[type=text]").val().split("")[0]; var width=width || 144; var height=width; var target=target || "body"; var id=davis.randomWord()+davis.random(100); var c=app.v.canvas(width,height,id); $(target).append(c); $("div#icons canvas#"+id).on("click",function(){ $("div#saved").prepend(this); if ($("div#icons > canvas").size()<5){ var iconWidth=$("input[name=size]:checked").val(); iconWidth=parseInt(iconWidth); app.v.icon("div#icons",iconWidth); ///console.log(iconWidth); } $("div#saved canvas#"+id).on("click",function(){ var dataURL = this.toDataURL(); if (!window.open(dataURL)) { document.location.href = dataURL; } }); //send it to the database if (app.m.password!=false){ var dataURL=document.getElementById(id).toDataURL(); $.ajax({ type: "POST", url: "http://peopleofthebit.com/luke_davis/labs/iconic/php/createRecord.php", data: {image:dataURL,password:app.m.password} }).done(function(o) { //console.log('saved'); }); } }); c=document.getElementById(id); var ctx=c.getContext("2d"); app.v.radial(ctx,width,height); davis.maybe(1,3,function(){ ctx.clearRect(0, 0, width, height); app.v.textIcon(ctx,width,height); }) //app.v.textIcon(ctx,width,height); //app.v.bilateral(ctx,width,height); //app.v.radial(ctx,width,height); }; app.v.textIcon=function(ctx,width,height){ctx.beginPath(); var color=davis.randomColor(); var gradient=ctx.createLinearGradient(0,0,0,height); gradient.addColorStop(0,color); gradient.addColorStop(1,davis.pick([color,davis.randomColor(),"#000","#fff",davis.alpha(color,0)])); ctx.fillStyle=gradient; ctx.fillRect(0,0,width,height); for (var j=0;j"; return c; }; app.v.style=function(){ davis.style("body",{ "width":"100%", "margin":"0px", "padding":"0px", "text-align":"center", "background":"#ddd" }); davis.style("canvas",{ "margin":"20px", "cursor":"pointer" }); davis.style("div",{ "text-align":"center", "border":"1px solid #111", "margin":"20px" }); davis.style("input[type=text]",{ "font-size":"3em", "color":"#111", "text-align":"center", "margin-top":"30px" }); davis.style("input[type=button]",{ "font-size":"3em", "width":"100%", "margin":"0px", "cursor":"pointer", "background":"#EC1313", "color":"#fff" }); davis.style("table",{ "width":"100%", "table-layout":"fixed", "text-align":"center" }); davis.style("input[type=radio]",{ "margin-top":"20px", "width":"20px", "height":"20px" }); davis.style("canvas",{ "width":"100px", "height":"100px" }); };