Example Scripts

Return to Introduction  Previous page  Next page

Example Scripts

Below is a selection of example 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)

}

 

ShapeScripts_Example1

//SINGLE CONDITIONAL SHAPE

shape main

{

 

       if (HasTag("Trigger","Link"))  

       {// Only draw if the object has a Tagged Value Trigger=Link

               // 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;

       }

}

 

ShapeScrips_Example4

//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;

       }

}

 

ShapeScrips_Example6

 

 

 

ShapeScrips_Example7

//SUB SHAPES

shape main

{

       rectangle(0,0,100,100);

       

       addsubshape("red",   10,  20);

       addsubshape("blue",  30,  40);

       addsubshape("green"50,  20);

       addsubshape("red",   10020);

       

       shape red

       {

               setfillcolor(20050100);

               rectangle(0,0,100,100);

       }

       

       shape blue

       {

               setfillcolor(10050200);

               rectangle(0,0,100,100);

       }

       

       shape green

       {

               setfillcolor(50200100);

               rectangle(0,0,100,100);

       }

}

 

SubShapes

//Editable Field Shape

shape main

{

       rectangle(0,0,100,100);

 

       addsubshape("namecompartment"10020);

       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#");

       }

}

 

Editable Field Shape

//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();

}

 

CloudPathExample

 

See Also