Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added rect.js to the build script, rebuilt donatello-min.js

  • Loading branch information...
commit cf57aaa30f76cc5530739568f1f36e3f53091c24 1 parent ae7a1dc
Dan Newcome authored

Showing 2 changed files with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. +1 1  build.sh
  2. +1 1  build/donatello-min.js
2  build.sh
... ... @@ -1,2 +1,2 @@
1 1 #!/bin/bash
2   -cat donatello.js circle.js ellipse.js arc.js line.js | uglifyjs > build/donatello-min.js
  2 +cat donatello.js rect.js circle.js ellipse.js arc.js line.js | uglifyjs > build/donatello-min.js
2  build/donatello-min.js
@@ -11,4 +11,4 @@
11 11 * id - id string of an existing DOM element or a reference
12 12 * to the DOM element itself.
13 13 * x/y, w/h - position and size
14   -*/function Donatello(a,b,c,d,e){this.properties={};if(typeof a=="string"){var f=document.getElementById(a);Donatello.createElement(b,c,d,e,f),this.dom=f}else a!=null&&(this.dom=a)}Donatello.getTransform=function(){var a,b=document.createElement("div");return Donatello.transform==undefined?(typeof b.style.transform!="undefined"?a="transform":typeof b.style.webkitTransform!="undefined"?a="webkitTransform":typeof b.style.MozTransform!="undefined"?a="MozTransform":typeof b.style.msTransform!="undefined"?a="msTransform":typeof b.style.OTransform!="undefined"?a="OTransform":a=null,console.log("css transform: "+a),Donatello.transform=a):a=Donatello.transform,a},Donatello.merge=function(a,b){for(var c in a)b[c]=a[c];return b},Donatello.prototype.attrMap={fill:"backgroundColor",stroke:"borderColor","stroke-style":"borderStyle",r:"borderRadius",type:null,children:null,transform:Donatello.getTransform()},Donatello.prototype.draw=function(){},Donatello.paper=function(a,b,c,d,e,f){return new Donatello(a,b,c,d,e,f)},Donatello.createLinearGradient=function(a,b,c){a=Math.floor(a/45);var d="center top, center bottom";switch(a){case 0:d="left center, right center";break;case 1:d="left bottom, right top";break;case 2:d="center bottom, center top";break;case 3:d="right bottom, left top";break;case 4:d="right center, left center";break;case 5:d="right top, left bottom";break;case 6:d="center top, center bottom";break;case 7:d="left top, right bottom";break;case 8:d="left center, right center"}var e;switch(Donatello.getTransform()){case"MozTransform":e="-moz-linear-gradient("+a*45+"deg,"+b+", "+c+")";break;case"webkitTransform":e="-webkit-gradient(linear, "+d+", from("+b+"), to("+c+"))";break;case"msTransform":var f=Math.floor(a%4/2);e="progid:DXImageTransform.Microsoft.gradient(GradientType="+f+', startColorstr="'+b+'", endColorstr="'+c+'")';break;case"OTransform":e="-o-linear-gradient("+a*45+"deg,"+b+","+c+")"}return e},Donatello.prototype.rotate=function(a){this.dom.style[Donatello.getTransform()]+="rotate("+a+"deg)"},Donatello.prototype.clear=function(){while(this.dom.hasChildNodes())this.dom.removeChild(this.dom.lastChild)},Donatello.prototype["delete"]=function(){this.dom.parentNode.removeChild(this.dom)},Donatello.prototype.node=function(){return this.dom},Donatello.prototype.attr=function(a){if(a=="undefined")return this.properties;Donatello.merge(a,this.properties);var b=this.attrMap;for(attr in a)if(b[attr]!=null)if(attr=="r"||attr=="stroke-width")this.dom.style[b[attr]]=a[attr]+"px";else if(attr=="fill")if(a.fill&&a.fill.length>7){var c=a.fill;this.dom.style.backgroundImage=Donatello.createLinearGradient(c.substr(0,2),c.substr(3,7),c.substr(11,7))}else this.dom.style[b[attr]]=a[attr];else attr!="scale"&&(this.dom.style[b[attr]]=a[attr]);else if(attr!="stroke-width"&&attr!="x"&&attr!="y"&&attr!="w"&&attr!="h"&&attr!="type"&&attr!="children")if(typeof this.styleableElements!="undefined")for(var d=0;d<this.styleableElements.length;d++)console.log("setting "+attr+" to "+a[attr]),this.styleableElements[d].style[attr]=a[attr];else this.dom.style[attr]=a[attr];return this.draw(),this},Donatello.createElement=function(a,b,c,d,e){var f;return typeof e=="string"?f=document.createElement(e):f=e,f.style.position="absolute",f.style.top=b+"px",f.style.left=a+"px",f.style.width=c+"px",f.style.height=d+"px",f},Donatello.attrDefaults=function(a){return a=a||{},a["stroke-width"]||(a["stroke-width"]=1),a.stroke||(a.stroke="black"),a.fill||(a.fill="transparent"),a["stroke-style"]||(a["stroke-style"]="solid"),a},Donatello.Circle=function(a,b,c,d,e){e=Donatello.attrDefaults(e);var f=e["stroke-width"],g=e.stroke,h=e.fill,i=e["stroke-style"];this.properties={x:b,y:c,r:d,"stroke-width":f,"stroke-style":i,stroke:g,fill:h};var j=Donatello.createElement(b-d-f,c-d-f,2*d,2*d,"div");a.dom.appendChild(j),this.dom=j,this.attr(e)},Donatello.Circle.prototype=new Donatello(null),Donatello.prototype.circle=function(a,b,c,d){return new Donatello.Circle(this,a,b,c,d)},Donatello.Circle.prototype.draw=function(){var a=this.properties.x,b=this.properties.y,c=this.properties.r,d=this.properties["stroke-width"],e=this.properties.stroke,f=this.properties.fill,g=this.properties["stroke-style"],h=this.dom;h.style.borderRadius=c+d+"px",h.style.borderWidth=d+"px",h.style.borderStyle=g,h.style.bordercolor=e,h.style.backgroundColor=f,h.style.left=a-c-d+"px",h.style.top=b-c-d+"px"},Donatello.Ellipse=function(a,b,c,d,e,f){f=Donatello.attrDefaults(f);var g=f["stroke-width"],h=f.stroke,i=f.fill,j=f["stroke-style"];this.properties={x:b,y:c,rx:d,ry:e,"stroke-width":g,"stroke-style":j,stroke:h,fill:i};var k=Donatello.createElement(b-d-g,c-e-g,2*d,2*e,"div");a.dom.appendChild(k),this.dom=k,this.attr(f)},Donatello.Ellipse.prototype=new Donatello(null),Donatello.prototype.ellipse=function(a,b,c,d,e){return new Donatello.Ellipse(this,a,b,c,d,e)},Donatello.Ellipse.prototype.draw=function(){var a=this.properties.x,b=this.properties.y,c=this.properties.r,d=this.properties.rx,e=this.properties.ry,f=this.properties["stroke-width"],g=this.properties.stroke,h=this.properties.fill,i=this.properties["stroke-style"],j=this.dom;j.style.borderRadius=d+f+"px / "+(e+f)+"px",j.style.borderWidth=f+"px",j.style.borderStyle=i,j.style.borderColor=g,j.style.backgroundColor=h,j.style.left=a-d-f+"px",j.style.top=b-e-f+"px"},Donatello.Arc=function(a,b,c,d,e,f,g){g=Donatello.attrDefaults(g);var h=g["stroke-width"],i=g.stroke,j=g.fill,k=g["stroke-style"];this.properties={x:b,y:c,r:d,t1:e,t2:f,"stroke-width":h,"stroke-style":k,stroke:i,fill:j};var l=f,m=Donatello.createElement(b-2*d,c-2*d,2*d,2*d,"div"),n=Donatello.createElement(d-h,d-h,2*d,2*d,"div"),o=Donatello.createElement(d-h,d-h,2*d,2*d,"div"),p=Donatello.createElement(d-h,d-h,2*d,2*d,"div"),q=Donatello.createElement(d-h,d-h,2*d,2*d,"div");m.appendChild(n),m.appendChild(o),m.appendChild(p),m.appendChild(q),this.styleableElements=[n,o,p,q],m.style[Donatello.transform+"Origin"]="100% 100%",a.dom.appendChild(m),this.dom=m,this.draw(f)},Donatello.Arc.prototype=new Donatello(null),Donatello.prototype.arc=function(a,b,c,d,e,f){return new Donatello.Arc(this,a,b,c,d,e,f)},Donatello.Arc.prototype.draw=function(a){function i(a,c){a.style.borderRadius=d+e+"px",a.style.borderWidth=e+"px",a.style.borderStyle=h,a.style.borderColor=f,a.style.borderBottomColor="transparent",a.style.borderLeftColor="transparent",a.style.borderRightColor="transparent",a.style.backgroundColor=g,b<90?a.style[Donatello.transform]="skew("+ -(90-b)+"deg)rotate("+(c-45)+"deg)":a.style[Donatello.transform]="rotate("+(c-45)+"deg)"}var b=a,c=this.properties.t1;b<90?(this.dom.style.overflow="hidden",this.dom.style[Donatello.transform]="rotate("+(180+c)+"deg)"+"skew("+(90-b)+"deg)"):(this.dom.style.overflow="visible",this.dom.style[Donatello.transform]="rotate("+(180+c)+"deg)"+"skew(0deg)");var d=this.properties.r,e=this.properties["stroke-width"],f=this.properties.stroke,g=this.properties.fill,h=this.properties["stroke-style"];for(var j=0;j<4;j++)i(this.dom.children[j],(b-90)*j/3)},Donatello.Line=function(a,b,c,d,e,f){f=Donatello.attrDefaults(f);var g=f["stroke-width"];this.properties={x:b,y:c,dx:d,dy:e,"stroke-width":g};var h=f.stroke,i=f.fill,j=f["stroke-style"],k=Donatello.createElement(b,c,0,0,"div");this.attrMap["stroke-width"]="borderTopWidth",this.attrMap["stroke-style"]="borderTopStyle",this.attrMap.stroke="borderTopColor",this.dom=k,this.draw(f),k.style[Donatello.getTransform()+"Origin"]="0px 0px",a.dom.appendChild(k),this.attr(f)},Donatello.Line.prototype=new Donatello(null),Donatello.Line.prototype.draw=function(a){var b=this.properties.x,c=this.properties.y,d=this.properties.dx,e=this.properties.dy,f=this.properties["stroke-width"],g=Math.sqrt(d*d+e*e);this.dom.style.width=g+"px",this.dom.style.height="0px";var h=Math.asin(Math.abs(e)/g);h*=180/Math.PI,d<0&&e>=0?h=180-h:d<0&&e<0?h=180+h:d>=0&&e<0&&(h=360-h),this.dom.style[Donatello.getTransform()]="rotate("+h+"deg) translate(0px, -"+f/2+"px)",this.dom.style.borderTopWidth=f+"px",this.dom.style.left=b+"px",this.dom.style.top=c+"px"},Donatello.prototype.line=function(a,b,c,d,e){return new Donatello.Line(this,a,b,c,d,e)}
  14 +*/function Donatello(a,b,c,d,e){this.properties={};if(typeof a=="string"){var f=document.getElementById(a);Donatello.createElement(b,c,d,e,f),this.dom=f}else a!=null&&(this.dom=a)}Donatello.getTransform=function(){var a,b=document.createElement("div");return Donatello.transform==undefined?(typeof b.style.transform!="undefined"?a="transform":typeof b.style.webkitTransform!="undefined"?a="webkitTransform":typeof b.style.MozTransform!="undefined"?a="MozTransform":typeof b.style.msTransform!="undefined"?a="msTransform":typeof b.style.OTransform!="undefined"?a="OTransform":a=null,console.log("css transform: "+a),Donatello.transform=a):a=Donatello.transform,a},Donatello.merge=function(a,b){for(var c in a)b[c]=a[c];return b},Donatello.prototype.attrMap={fill:"backgroundColor",stroke:"borderColor","stroke-style":"borderStyle",r:"borderRadius",type:null,children:null,transform:Donatello.getTransform()},Donatello.prototype.draw=function(){},Donatello.paper=function(a,b,c,d,e,f){return new Donatello(a,b,c,d,e,f)},Donatello.createLinearGradient=function(a,b,c){a=Math.floor(a/45);var d="center top, center bottom";switch(a){case 0:d="left center, right center";break;case 1:d="left bottom, right top";break;case 2:d="center bottom, center top";break;case 3:d="right bottom, left top";break;case 4:d="right center, left center";break;case 5:d="right top, left bottom";break;case 6:d="center top, center bottom";break;case 7:d="left top, right bottom";break;case 8:d="left center, right center"}var e;switch(Donatello.getTransform()){case"MozTransform":e="-moz-linear-gradient("+a*45+"deg,"+b+", "+c+")";break;case"webkitTransform":e="-webkit-gradient(linear, "+d+", from("+b+"), to("+c+"))";break;case"msTransform":var f=Math.floor(a%4/2);e="progid:DXImageTransform.Microsoft.gradient(GradientType="+f+', startColorstr="'+b+'", endColorstr="'+c+'")';break;case"OTransform":e="-o-linear-gradient("+a*45+"deg,"+b+","+c+")"}return e},Donatello.prototype.rotate=function(a){this.dom.style[Donatello.getTransform()]+="rotate("+a+"deg)"},Donatello.prototype.clear=function(){while(this.dom.hasChildNodes())this.dom.removeChild(this.dom.lastChild)},Donatello.prototype["delete"]=function(){this.dom.parentNode.removeChild(this.dom)},Donatello.prototype.node=function(){return this.dom},Donatello.prototype.attr=function(a){if(a=="undefined")return this.properties;Donatello.merge(a,this.properties);var b=this.attrMap;for(attr in a)if(b[attr]!=null)if(attr=="r"||attr=="stroke-width")this.dom.style[b[attr]]=a[attr]+"px";else if(attr=="fill")if(a.fill&&a.fill.length>7){var c=a.fill;this.dom.style.backgroundImage=Donatello.createLinearGradient(c.substr(0,2),c.substr(3,7),c.substr(11,7))}else this.dom.style[b[attr]]=a[attr];else attr!="scale"&&(this.dom.style[b[attr]]=a[attr]);else if(attr!="stroke-width"&&attr!="x"&&attr!="y"&&attr!="w"&&attr!="h"&&attr!="type"&&attr!="children")if(typeof this.styleableElements!="undefined")for(var d=0;d<this.styleableElements.length;d++)console.log("setting "+attr+" to "+a[attr]),this.styleableElements[d].style[attr]=a[attr];else this.dom.style[attr]=a[attr];return this.draw(),this},Donatello.createElement=function(a,b,c,d,e){var f;return typeof e=="string"?f=document.createElement(e):f=e,f.style.position="absolute",f.style.top=b+"px",f.style.left=a+"px",f.style.width=c+"px",f.style.height=d+"px",f},Donatello.attrDefaults=function(a){return a=a||{},a["stroke-width"]||(a["stroke-width"]=1),a.stroke||(a.stroke="black"),a.fill||(a.fill="transparent"),a["stroke-style"]||(a["stroke-style"]="solid"),a},Donatello.prototype.rect=function(a,b,c,d,e){return this.pgram(a,b,c,d,null,e)},Donatello.Pgram=function(a,b,c,d,e,f,g){g=Donatello.attrDefaults(g);var h=Donatello.createElement(b,c,d,e,"div"),i=g["stroke-width"],j=g.stroke,k=g.fill,l=g["stroke-style"];this.properties={x:b,y:c,dx:e,skew:f,"stroke-width":i,"stroke-style":l,stroke:j,fill:k},a.dom.appendChild(h),this.dom=h,this.attr(g)},Donatello.Pgram.prototype=new Donatello(null),Donatello.Pgram.prototype.draw=function(){var a=this.dom,b=this.properties.skew;a.style.borderWidth=this.properties["stroke-width"]+"px",b!=null&&(a.style[Donatello.getTransform()]+="skew("+b+"deg)")},Donatello.prototype.pgram=function(a,b,c,d,e,f){return new Donatello.Pgram(this,a,b,c,d,e,f)},Donatello.Circle=function(a,b,c,d,e){e=Donatello.attrDefaults(e);var f=e["stroke-width"],g=e.stroke,h=e.fill,i=e["stroke-style"];this.properties={x:b,y:c,r:d,"stroke-width":f,"stroke-style":i,stroke:g,fill:h};var j=Donatello.createElement(b-d-f,c-d-f,2*d,2*d,"div");a.dom.appendChild(j),this.dom=j,this.attr(e)},Donatello.Circle.prototype=new Donatello(null),Donatello.prototype.circle=function(a,b,c,d){return new Donatello.Circle(this,a,b,c,d)},Donatello.Circle.prototype.draw=function(){var a=this.properties.x,b=this.properties.y,c=this.properties.r,d=this.properties["stroke-width"],e=this.properties.stroke,f=this.properties.fill,g=this.properties["stroke-style"],h=this.dom;h.style.borderRadius=c+d+"px",h.style.borderWidth=d+"px",h.style.borderStyle=g,h.style.bordercolor=e,h.style.backgroundColor=f,h.style.left=a-c-d+"px",h.style.top=b-c-d+"px"},Donatello.Ellipse=function(a,b,c,d,e,f){f=Donatello.attrDefaults(f);var g=f["stroke-width"],h=f.stroke,i=f.fill,j=f["stroke-style"];this.properties={x:b,y:c,rx:d,ry:e,"stroke-width":g,"stroke-style":j,stroke:h,fill:i};var k=Donatello.createElement(b-d-g,c-e-g,2*d,2*e,"div");a.dom.appendChild(k),this.dom=k,this.attr(f)},Donatello.Ellipse.prototype=new Donatello(null),Donatello.prototype.ellipse=function(a,b,c,d,e){return new Donatello.Ellipse(this,a,b,c,d,e)},Donatello.Ellipse.prototype.draw=function(){var a=this.properties.x,b=this.properties.y,c=this.properties.r,d=this.properties.rx,e=this.properties.ry,f=this.properties["stroke-width"],g=this.properties.stroke,h=this.properties.fill,i=this.properties["stroke-style"],j=this.dom;j.style.borderRadius=d+f+"px / "+(e+f)+"px",j.style.borderWidth=f+"px",j.style.borderStyle=i,j.style.borderColor=g,j.style.backgroundColor=h,j.style.left=a-d-f+"px",j.style.top=b-e-f+"px"},Donatello.Arc=function(a,b,c,d,e,f,g){g=Donatello.attrDefaults(g);var h=g["stroke-width"],i=g.stroke,j=g.fill,k=g["stroke-style"];this.properties={x:b,y:c,r:d,t1:e,t2:f,"stroke-width":h,"stroke-style":k,stroke:i,fill:j};var l=f,m=Donatello.createElement(b-2*d,c-2*d,2*d,2*d,"div"),n=Donatello.createElement(d-h,d-h,2*d,2*d,"div"),o=Donatello.createElement(d-h,d-h,2*d,2*d,"div"),p=Donatello.createElement(d-h,d-h,2*d,2*d,"div"),q=Donatello.createElement(d-h,d-h,2*d,2*d,"div");m.appendChild(n),m.appendChild(o),m.appendChild(p),m.appendChild(q),this.styleableElements=[n,o,p,q],m.style[Donatello.transform+"Origin"]="100% 100%",a.dom.appendChild(m),this.dom=m,this.draw(f)},Donatello.Arc.prototype=new Donatello(null),Donatello.prototype.arc=function(a,b,c,d,e,f){return new Donatello.Arc(this,a,b,c,d,e,f)},Donatello.Arc.prototype.draw=function(a){function i(a,c){a.style.borderRadius=d+e+"px",a.style.borderWidth=e+"px",a.style.borderStyle=h,a.style.borderColor=f,a.style.borderBottomColor="transparent",a.style.borderLeftColor="transparent",a.style.borderRightColor="transparent",a.style.backgroundColor=g,b<90?a.style[Donatello.transform]="skew("+ -(90-b)+"deg)rotate("+(c-45)+"deg)":a.style[Donatello.transform]="rotate("+(c-45)+"deg)"}var b=a,c=this.properties.t1;b<90?(this.dom.style.overflow="hidden",this.dom.style[Donatello.transform]="rotate("+(180+c)+"deg)"+"skew("+(90-b)+"deg)"):(this.dom.style.overflow="visible",this.dom.style[Donatello.transform]="rotate("+(180+c)+"deg)"+"skew(0deg)");var d=this.properties.r,e=this.properties["stroke-width"],f=this.properties.stroke,g=this.properties.fill,h=this.properties["stroke-style"];for(var j=0;j<4;j++)i(this.dom.children[j],(b-90)*j/3)},Donatello.Line=function(a,b,c,d,e,f){f=Donatello.attrDefaults(f);var g=f["stroke-width"];this.properties={x:b,y:c,dx:d,dy:e,"stroke-width":g};var h=f.stroke,i=f.fill,j=f["stroke-style"],k=Donatello.createElement(b,c,0,0,"div");this.attrMap["stroke-width"]="borderTopWidth",this.attrMap["stroke-style"]="borderTopStyle",this.attrMap.stroke="borderTopColor",this.dom=k,this.draw(f),k.style[Donatello.getTransform()+"Origin"]="0px 0px",a.dom.appendChild(k),this.attr(f)},Donatello.Line.prototype=new Donatello(null),Donatello.Line.prototype.draw=function(a){var b=this.properties.x,c=this.properties.y,d=this.properties.dx,e=this.properties.dy,f=this.properties["stroke-width"],g=Math.sqrt(d*d+e*e);this.dom.style.width=g+"px",this.dom.style.height="0px";var h=Math.asin(Math.abs(e)/g);h*=180/Math.PI,d<0&&e>=0?h=180-h:d<0&&e<0?h=180+h:d>=0&&e<0&&(h=360-h),this.dom.style[Donatello.getTransform()]="rotate("+h+"deg) translate(0px, -"+f/2+"px)",this.dom.style.borderTopWidth=f+"px",this.dom.style.left=b+"px",this.dom.style.top=c+"px"},Donatello.prototype.line=function(a,b,c,d,e){return new Donatello.Line(this,a,b,c,d,e)}

0 comments on commit cf57aaa

Please sign in to comment.
Something went wrong with that request. Please try again.