Join
Google+

User:
Pass:
Save:

New Demos

Top Demos

Web Tools   (13)


Android (1) Archive (7) Audio (1) C64 (1) Construct2 (1) Ebook (2) Flash (25) Html5 (4) Image (39) Java (1) Javascript (19) Stylesheet (1) SVG (2) - RaphaelJS - WebGL - Unity - Box2D

Top Author






Top Reviewer






Top Commenter






paint

function cLum(a) { for (var b=0;b=d?(c+0.05)/(d+0.05):(d+0.05)/(c+0.05); return Math.round(e*100)/100; } function cStrNorm(a) { var b; if (a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)) { return a; } if (b=a.match(/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/)) { b.shift(); return "rgb("+$.map(b,function(a) { return parseInt(a,16).toString()}).join(", ")+")"; } if ("getComputedStyle" in window) { document.body.style.color=a; return cStrNorm(window.getComputedStyle(document.body,null).color); } if (document.body.currentStyle) { document.body.style.color=a; return cStrNorm(document.body.currentStyle.color); } return a; } function cStrParse(a) { var b=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); if (b) { b.shift(); return $.map(b,function(a) { return parseInt(a,10); }); } return cStrParse(cStrNorm(a)); } $(document).ready(function() { var a=1,b=2,c=4,d=8,e=[c,d,a,b],f=a,g=16,h=32,i=32,j=h*g,k=i*g, l=new Array(i), pix=$("#pixels"), grid=$("#grid").get(0).getContext("2d"), thumb=$("#preview").get(0), preview=thumb.getContext("2d"), q="localStorage" in window && window.localStorage!==null, paint="Paint:", bkcolor="background-color", t=cStrParse("rgb(255,255,255)"), u=$("#color div"), v="rgb(0,0,0)"; function w(a) { v=cStrNorm(a); var b=cStrParse(v),c=cCon(b,t),d=$.map(b,function(a) { var b=a.toString(16); return b.length==1?"0"+b:b; }); u.css(bkcolor,v); u.css("text-shadow",c<4||c>10?"none":"0 0 3px rgba(0, 0, 0, 0.7)"); u.css("color",c>=4?"white":"black"); u.text("#"+d.join("").toUpperCase()); } function x(a,b) { a.color=b; if (b===undefined) { $(a).css(bkcolor,""); preview.clearRect(a.i,a.j,1,1); } else { $(a).css(bkcolor,b); preview.fillStyle=b; preview.fillRect(a.i,a.j,1,1); } if (q) { var persist=paint+a.i+":"+a.j; b===undefined?delete localStorage[persist]:localStorage[persist]=b; } } function y(a,b,c,d) { var e=[],f=l[b][a].get(0); e.push(f); while (e.length>0) { f=e.shift(); f.color===c&&x(f,d); var g=[[f.j-1,f.i],[f.j,f.i+1],[f.j+1,f.i],[f.j,f.i-1]]; for (var h=0;h<4;h++) { var f=(l[g[h][0]]||{})[g[h][1]]; if (f!==undefined) { f=f.get(0); if (f.color===c) { x(f,d); e.push(f); } } } } } pix.click(function(e) { var g=e.target; f==a?x(g,v):f==b?y(g.i,g.j,g.color,v):f==c?x(g,undefined):f==d&&g.color!==undefined&&w(g.color); }); for (var z=0;z
' + name + ' Click..
').hide().fadeIn(1000); // setTimeout(function(){ $('#respond').fadeOut(1000); }, 2000); // todo: make option to view unsaved image // if (!saved) { // document.location.href = thumb.toDataURL("image/png"); // } else { var image = thumb.toDataURL("image/png"); // } // find bug on Android.. // alert(image); if (image) { var order = { user: user, name: name , image: image }; // alert(id + " , " + name + " , " + user); $.post('/user/save-sprite.php', 'data=' + $.toJSON(order), function(response) { if (response == "success") $("#respond").html('
' + name + ' Saved!
').hide().fadeIn(1000); setTimeout(function(){ $('#respond').fadeOut(1000); }, 2000); }); } }); $("#tools").click( function(a) { var b=$(a.target).closest("li"); if (b.length>0) { f=e[b.index()]; $("#tools .selected").removeClass("selected"); b.addClass("selected"); } }); $("#palette").click( function(a) { var b=$(a.target).closest("li"); b.length>0&&w(b.css(bkcolor)); }); $("#palette li").each( function() { var a=$(this); a.css("background",a.text()); }); $("#color").click( function() { var a=prompt("Please enter a color, e.g. red, #00FF00, rgb(0, 0, 255)",u.text()); typeof a=="string"&&$.trim(a)!==""&&w(a); }); $("#info").click( function() { var n=prompt("Please enter sprite name",$("#info").text()); typeof n=="string"&&$.trim(n)!==""&&$("#name").text(n); }); w("Black"); }); // end of file

About: Testing Canvas..

Info: Testing Canvas..


Category: Javascript

Genre: app

Type: testing


Site: http://timcraft.com

Author: tim craft


Viewed: 2017-04-26 02:51:56

Views: 18088


paint.js

Downloads: 0

Rating: 7

Rate: 1 2 3 4 5 6 7 8 9 10


Comments welcome.


New Comment

Title:        By:



{kustomzone.com}