Example Scripts
Below is a selection of example Shape Scripts.
Code |
Result |
//BASIC SHAPES shape main { setfillcolor(255,0,0); // (R,G,B) rectangle(0,0,90,30); // (x1,y1,x2,y2)
setfillcolor(0,255,0); // (R,G,B) ellipse(0,30,90,60); // (x1,y1,x2,y2)
setfillcolor(0,0,255); // (R,G,B) rectangle(0,60,90,90); // (x1,y1,x2,y2) } |
|
//SINGLE CONDITIONAL SHAPE shape main { if (HasTag("Trigger","Link")) {// Only draw if the object has a Tagged Value // Set the fill color for the path setfillcolor(0,0,0); startpath(); // Start to trace out a path moveto(23,40); lineto(23,60); lineto(50,60); lineto(50,76); lineto(76,50); lineto(50,23); lineto(50,40); endpath(); // End tracing out a path // Fill the traced path with the fill color fillandstrokepath(); return; } } |
|
//MULTI CONDITIONAL SHAPE shape main { startpath(); ellipse(0,0,100,100); endpath(); fillandstrokepath(); ellipse(3,3,27,27);
if (HasTag("Trigger","None")) { return; }
if (HasTag("Trigger","Error")) { setfillcolor(0,0,0); startpath(); moveto(23,77); lineto(37,40); lineto(60,47); lineto(77,23); lineto(63,60); lineto(40,53); lineto(23,77); endpath(); fillandstrokepath(); return; } if (HasTag("Trigger","Message")) { rectangle(22,22,78,78); moveto(22,22); lineto(50,50); lineto(78,22); return; } } |
|
//SUB SHAPES shape main { rectangle(0,0,100,100);
addsubshape("red", 10, 20); addsubshape("blue", 30, 40); addsubshape("green", 50, 20); addsubshape("red", 100, 20);
shape red { setfillcolor(200, 50, 100); rectangle(0,0,100,100); }
shape blue { setfillcolor(100, 50, 200); rectangle(0,0,100,100); }
shape green { setfillcolor(50, 200, 100); rectangle(0,0,100,100); } } |
|
//Editable Field Shape shape main { rectangle(0,0,100,100);
addsubshape("namecompartment", 100, 20); addsubshape("stereotypecompartment", 100, 40);
shape namecompartment { h_align = "center"; editablefield = "name";
rectangle(0,0,100,100); println("name: #name#"); }
shape stereotypecompartment { h_align = "center"; editablefield = "stereotype";
rectangle(0,0,100,100); println("stereotype: #stereotype#"); } } |
|
//Return Statement Shape shape main { if(hasTag("alternatenotation", "false")) { //draw ea's inbuild glyph drawnativeshape(); //exit script with the return statement return; }
//alternate notation commands //... rectangle(0,0,100,100); } |
|
//Cloud Path Example Shape shape main { StartCloudPath(); Rectangle(0,0,100,100); EndPath(); FillAndStrokePath(); } |
|
// Connector Example shape main { // draw a dashed line noshadow=true; setlinestyle("DASH"); moveto(0,0); lineto(100,0); }
shape source { // draw a circle at the source end rotatable = true; startpath(); ellipse(0,6,12,-6); endpath(); fillandstrokepath(); }
shape target { // draw an arrowhead at the target end rotatable = true; startpath(); moveto(0,0); lineto(16,6); lineto(16,-6); endpath(); fillandstrokepath(); } |
|
// Double Line shape main { noshadow=true; moveto(0,-10); lineto(100,-10); moveto(0,10); lineto(100,10); } |
|










