From 6467c4929a2ee430af64f48460deb748c0736e79 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Mon, 23 Jul 2012 15:26:26 +0300 Subject: nice two polygons --- base.js | 49 +++++++++++++++++++++++++++++++++++++++++++------ index.html | 11 ++++++++++- sha1.js | 14 ++++++++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 sha1.js diff --git a/base.js b/base.js index 8d02dca..b0fd8ea 100644 --- a/base.js +++ b/base.js @@ -1,10 +1,47 @@ -gen = function() { - var paper = Raphael('canvas', 250, 250); - var circle = paper.circle(50, 40, 10); - circle.attr("fill", "#f00"); - circle.attr("stroke", "#fff"); +curve = function(x, y , ax, bx, ay, by, zx, zy, color) { + +}; + +gen = function(s, c) { + var h = CryptoJS.SHA1(s).toString(CryptoJS.enc.Hex); + var v = []; + + for (var i=0; i<20; i++) { + var bt = parseInt(h.substring(2*i, 2*(i+1)), 16); + v.push(bt); + } + + console.log(v); + + var r = Raphael(c, 250, 250); + var hv = v[4] / 256; + var sv = v[5] / 256; + var bv = v[6] / 256; + r.path(['M', v[0], 0, 'L', 0, v[1], 'L', v[2], 250, 'L', 250, v[3], 'Z']).attr({ + fill: Raphael.hsb(hv, sv, bv), + stroke: Raphael.hsb(hv, sv, bv) + }); + + hv = v[11] / 256; + sv = v[12] / 256; + bv = v[13] / 256; + r.path(['M', v[7], 0, 'L', 0, v[8], 'L', v[9], 250, 'L', 250, v[10], 'Z']).attr({ + fill: Raphael.hsb(hv, sv, bv), + stroke: Raphael.hsb(hv, sv, bv), + 'fill-opacity': (v[14] / 512) + 0.3, + 'stroke-opacity': (v[14] / 512) + 0.3 + }); + + }; $(document).ready(function() { - gen(); + gen('yuvals', 'c1'); + gen('yuvalsx', 'c2'); + gen('yuvalsd', 'c3'); + gen('yuvalse', 'c4'); + gen('yuv', 'c5'); + gen('yals', 'c6'); + gen('yuvl11', 'c7'); + gen('yuvals1242346', 'c8'); }); diff --git a/index.html b/index.html index 3d83c7d..3ceaad1 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ + @@ -14,6 +15,14 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/sha1.js b/sha1.js new file mode 100644 index 0000000..fede7e2 --- /dev/null +++ b/sha1.js @@ -0,0 +1,14 @@ +/* +CryptoJS v3.0.2 +code.google.com/p/crypto-js +(c) 2009-2012 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +var CryptoJS=CryptoJS||function(i,m){var p={},h=p.lib={},n=h.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),o=h.WordArray=n.extend({init:function(a,b){a= +this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||e).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var f=0;f>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= +n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= +a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); +this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- +899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); -- cgit v1.3.1