feat: draw.io custom shapes analysis + buildable example plugin
- ANALYSIS.md: Full architecture analysis of draw.io shape systems (XML stencils vs JS shapes, plugin loading, desktop/web support) - Example plugin with 5 custom shapes demonstrating JS logic: - StatusIndicator: conditional rendering based on status param - ProgressBar: computed geometry (percentage-based fill) - DataFlowArrow: dynamic arrows with direction/speed params - HexagonCluster: loop-based hexagonal grid generation - MetricGauge: radial gauge with arc computation + zones - Webpack build pipeline (npm run build / build:dev / watch) - Pre-built dist/drawio-custom-shapes.js ready for installation - Full README with installation instructions for desktop + web
This commit is contained in:
1 parent
f36600006c
commit
3347cc342c
14 files changed
+2835
-2
No files matched your search
Vendored
+1
@@ -0,0 +1 @@
|
||||
(()=>{var e={294(){function e(){mxShape.call(this)}mxUtils.extend(e,mxShape),e.prototype.cst={SHAPE:"customShapes.dataFlowArrow"},e.prototype.customProperties=[{name:"direction",dispName:"Direction",type:"enum",defVal:"right",enumList:[{val:"right",dispName:"Right"},{val:"left",dispName:"Left"},{val:"both",dispName:"Bidirectional"}]},{name:"flowSpeed",dispName:"Flow Speed",type:"enum",defVal:"medium",enumList:[{val:"fast",dispName:"Fast"},{val:"medium",dispName:"Medium"},{val:"slow",dispName:"Slow"}]}],e.prototype.paintVertexShape=function(e,t,o,l,r){e.translate(t,o);var a=mxUtils.getValue(this.style,"direction","right"),s=mxUtils.getValue(this.style,"flowSpeed","medium"),n=mxUtils.getValue(this.style,"flowColor","#1976D2"),i=parseInt(mxUtils.getValue(this.style,"thickness","3")),m=r/2,p=Math.min(r/2,12),h="left"===a||"both"===a?p:0,u="right"===a||"both"===a?l-p:l;e.setStrokeColor(n),e.setStrokeWidth(i),e.setFillColor(n),e.begin(),e.moveTo(h,m),e.lineTo(u,m),e.stroke(),"right"!==a&&"both"!==a||(e.begin(),e.moveTo(l-p,m-p),e.lineTo(l,m),e.lineTo(l-p,m+p),e.close(),e.fillAndStroke()),"left"!==a&&"both"!==a||(e.begin(),e.moveTo(p,m-p),e.lineTo(0,m),e.lineTo(p,m+p),e.close(),e.fillAndStroke());var c={fast:8,medium:14,slow:22},x=c[s]||c.medium,d=Math.max(2,.8*i);e.setFillColor("#FFFFFF"),e.setStrokeWidth(0);for(var C=h+x;C<u-x/2;C+=x)e.ellipse(C-d,m-d,2*d,2*d),e.fill();e.setStrokeColor(n),e.setAlpha(.15),e.setStrokeWidth(3*i),e.begin(),e.moveTo(h,m),e.lineTo(u,m),e.stroke()},mxCellRenderer.registerShape(e.prototype.cst.SHAPE,e)},421(){function e(){mxShape.call(this)}mxUtils.extend(e,mxShape),e.prototype.cst={SHAPE:"customShapes.hexCluster"},e.prototype.customProperties=[{name:"hexCount",dispName:"Hex Count (across)",type:"int",min:1,max:10,defVal:3},{name:"hexFill",dispName:"Hex Fill Color",type:"color",defVal:"#E3F2FD"},{name:"hexStroke",dispName:"Hex Stroke Color",type:"color",defVal:"#1565C0"}],e.prototype.drawHexagon=function(e,t,o,l){e.begin();for(var r=0;r<6;r++){var a=Math.PI/3*r-Math.PI/6,s=t+l*Math.cos(a),n=o+l*Math.sin(a);0===r?e.moveTo(s,n):e.lineTo(s,n)}e.close()},e.prototype.paintVertexShape=function(e,t,o,l,r){e.translate(t,o);var a=parseInt(mxUtils.getValue(this.style,"hexCount","3")),s=mxUtils.getValue(this.style,"hexFill","#E3F2FD"),n=mxUtils.getValue(this.style,"hexStroke","#1565C0"),i=mxUtils.getValue(this.style,"filled",""),m=r-8,p=(l-8)/(a=Math.max(1,Math.min(10,a))),h=p/Math.sqrt(3),u=1.5*h,c=Math.max(1,Math.floor((m-.5*h)/u)),x={};i&&i.split(",").forEach(function(e){x[parseInt(e.trim())]=!0});var d=0;e.setStrokeColor(n),e.setStrokeWidth(1.5);for(var C=0;C<c;C++)for(var S=C%2==0?a:a-1,g=C%2==0?0:p/2,f=0;f<S;f++){var F=4+g+p/2+f*p,k=4+h+C*u;if(!(k+h>r)){var y=""===i||x[d];e.setFillColor(y?s:"#FAFAFA"),e.setAlpha(y?1:.5),this.drawHexagon(e,F,k,.9*h),e.fillAndStroke(),e.setAlpha(1),d++}}e.setStrokeColor(n),e.setStrokeWidth(1),e.setAlpha(.3),e.setDashed(!0),e.rect(0,0,l,r),e.stroke()},mxCellRenderer.registerShape(e.prototype.cst.SHAPE,e)},504(){function e(){mxShape.call(this)}mxUtils.extend(e,mxShape),e.prototype.cst={SHAPE:"customShapes.metricGauge"},e.prototype.customProperties=[{name:"value",dispName:"Value",type:"float",defVal:75},{name:"minVal",dispName:"Min Value",type:"float",defVal:0},{name:"maxVal",dispName:"Max Value",type:"float",defVal:100},{name:"zones",dispName:"Zone Colors (comma-sep)",type:"string",defVal:"#4CAF50,#FF9800,#F44336"},{name:"label",dispName:"Label",type:"string",defVal:""}],e.prototype.paintVertexShape=function(e,t,o,l,r){e.translate(t,o);var a=parseFloat(mxUtils.getValue(this.style,"value","75")),s=parseFloat(mxUtils.getValue(this.style,"minVal","0")),n=parseFloat(mxUtils.getValue(this.style,"maxVal","100")),i=mxUtils.getValue(this.style,"zones","#4CAF50,#FF9800,#F44336"),m=mxUtils.getValue(this.style,"label",""),p=parseInt(mxUtils.getValue(this.style,"arcWidth","8")),h=i.split(","),u=l/2,c=.7*r,x=Math.min(l/2,.65*r)-p,d=Math.PI,C=Math.PI,S=h.length,g=C/S;e.setStrokeWidth(p),e.setLineCap("round");for(var f=0;f<S;f++){e.setStrokeColor(h[f]),e.setAlpha(.3);var F=d-f*g,k=F-g;e.begin();for(var y=0;y<=20;y++){var V=F+y/20*(k-F),E=u+x*Math.cos(V),w=c-x*Math.sin(V);0===y?e.moveTo(E,w):e.lineTo(E,w)}e.stroke()}var v=Math.max(0,Math.min(1,(a-s)/(n-s))),A=d-C*v,T=h[Math.min(S-1,Math.floor(v*S))];e.setStrokeColor(T),e.setAlpha(1),e.setStrokeWidth(p);var M=Math.max(2,Math.floor(40*v));for(e.begin(),y=0;y<=M;y++)V=d+y/M*(A-d),E=u+x*Math.cos(V),w=c-x*Math.sin(V),0===y?e.moveTo(E,w):e.lineTo(E,w);e.stroke(),e.setStrokeColor("#333333"),e.setStrokeWidth(2),e.setAlpha(1);var b=.85*x,N=u+b*Math.cos(A),P=c-b*Math.sin(A);e.begin(),e.moveTo(u,c),e.lineTo(N,P),e.stroke(),e.setFillColor("#333333"),e.ellipse(u-4,c-4,8,8),e.fill(),e.setFontColor("#333333"),e.setFontSize(Math.min(.4*x,24)),e.setFontStyle(1),e.text(u,c+.25*x,0,0,String(Math.round(10*a)/10),mxConstants.ALIGN_CENTER,mxConstants.ALIGN_MIDDLE,0,null,0,0,0),m&&(e.setFontColor("#666666"),e.setFontSize(Math.min(.2*x,12)),e.setFontLine truncated
|
||||
Reference in new issue
Block a user