Book a Demo

Author Topic: Draw shapescript subshapes without color gradient  (Read 7211 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Draw shapescript subshapes without color gradient
« on: December 13, 2020, 06:50:52 pm »
Hi,

I've been asked to create a shapescript similar to that of the process in EA's analysis toolbox.
I first did with a simple single shape approach, but the problem is that the start and end angles change when resizing the element (because they are defined in relative rather then absolute size)
The solution would then be to use the border layout with preferred width for bot sections, so only the middle section would elongate when changing the size.

This works just fine, with one problem: each subshape keeps it's own color gradient, making it look like three shapes stitches together.
Does anyone know if it's possible to either get

- a gradient over the complete shape
- no gradient at all

Here's wat the result looks like now


https://imgur.com/03s6S9p

And here's the shapescript

Code: [Select]
shape main

{

layouttype="border";
noshadow=true;
//set the fill color based on tagged value "heat map"
if(hastag("heat map","good"))
{
//light green
SetFillColor(112,255,145);
}
else if(hastag("heat map","problematic"))
{
//light yellow
SetFillColor(255,253,170);
}
else if(hastag("heat map","poor"))
{
//light red
SetFillColor(255,142,142);
}
else if(hastag("heat map","not evaluated"))
{
//white
SetFillColor(255,255,255);
}
else if(hastag("heat map","missing"))
{
//light purple
SetFillColor(227,168,255);
}
else
{
//default white
setfillcolor(255,255,255);
}

//main shape
setFontColor(0,0,0);


//fillandstrokepath();     
//subshapes
StartPath();
addsubshape("left","W");
addsubshape("center","center");
addsubshape("right","E");
Endpath();
FillAndStrokePath();


shape left
{
noshadow=true;
preferredWidth=20;
StartPath();
moveto(100,0);
lineto(0,0);
lineto(100,50);
lineto(0,100);
lineto(100,100);
endpath();
FillPath();
//draw outline
moveto(100,0);
lineto(0,0);
lineto(100,50);
lineto(0,100);
lineto(100,100);
}

shape right
{
preferredWidth=20;
StartPath();
MoveTo(0,0);
lineto(100,50);
lineto(0,100);
endpath();
FillPath();
//draw outline
MoveTo(0,0);
lineto(100,50);
lineto(0,100);
}

shape right
{
preferredWidth=30;
}
shape padding
{
preferredheight=10;
}

shape center
{
layouttype="border";

startPath();
rectangle(0,0,100,100);
// moveto(0,0);
// lineto(100,0);
// moveto(0,100);
// lineto(100,100);
endPath();
fillPath();
moveto(0,0);
lineto(100,0);
moveto(0,100);
lineto(100,100);

addsubshape("padding","n");
addsubshape("name","center");
shape name
{
v_align="top";
h_align="center";
printwrapped("#name#");
}
shape padding
{
preferredheight=10;
}
}
}

decoration composite
{
orientation="SW";
if(hasproperty("iscomposite","true"))
{
ellipse(0,40,40,60);
ellipse(60,40,100,60);
moveto(30,50);
lineto(70,50);
}
}

Thanks

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Draw shapescript subshapes without color gradient
« Reply #1 on: December 13, 2020, 07:38:31 pm »
The only alernative is to draw the shape as a whole which then would make the ends stretch relatively. Die the one or the other way :-/

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Draw shapescript subshapes without color gradient
« Reply #2 on: December 13, 2020, 09:56:45 pm »
The only alternative is to draw the shape as a whole which then would make the ends stretch relatively. Die the one or the other way :-/

q.
Hi Geert,

Qwerty is correct.  We stopped using Gradient Fill many years ago.  Unfortunately, for the shapes we create it's more trouble than it's worth.

It's a shame.  Perhaps put in a feature request to allow a parameter to set the whole shape to gradient fill if the background colour is the same?

IIRC you can't gradient fill on a per-shape or per-diagram basis - it would be good if you could.

Paolo
« Last Edit: December 14, 2020, 08:59:38 am by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Draw shapescript subshapes without color gradient
« Reply #3 on: December 13, 2020, 10:34:52 pm »
Indeed, if I turn off the fradient, or set it to "up" or "down" it looks just fine.
Maybe that is an option for my client, thanks for the suggestion.

I would even be happy with a "nogradient" parameter in the shapescript (similar to the noShadow) so we can turn if off for our shapes.

Geert

Takeshi K

  • EA User
  • **
  • Posts: 632
  • Karma: +43/-1
    • View Profile
    • Sparx Systems Japan
Re: Draw shapescript subshapes without color gradient
« Reply #4 on: December 14, 2020, 12:29:34 pm »
Helo Geert,

Does the following shapescript satisfy your request?

Code: [Select]
shape main
{

layouttype="border";
noshadow=true;

//delete color setting for the tagged value to be simple
setfillcolor(255,255,255);

//main shape
setFontColor(0,0,0);

startPath();
setfixedregion(80,0,100,0);
moveto(0,0);
lineto(80,0);
lineto(100,50);
lineto(80,100);
setfixedregion(0,0,20,0);
lineto(0,100);
lineto(20,50);
lineto(0,0);
endPath();
fillandstrokePath();

addsubshape("padding","n");
addsubshape("name","center");
shape name
{
v_align="top";
h_align="center";
printwrapped("#name#");
}
shape padding
{
preferredheight=10;
}
}

HTH,
--
t-kouno

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Draw shapescript subshapes without color gradient
« Reply #5 on: December 14, 2020, 05:41:27 pm »
Hi Takeshi,

That works, briljant!

It shouldn't work though.

The documentation says about SetFixedRegion

Quote
Fixes a region in a connector into which a sub-shape can be drawn, so that the sub-shape is not rescaled with the length or orientation of the connector line.

For an example, see the 'Rotation Direction' script in the Example Scripts topic.

But I'm glad it does in fact work.

Thanks a lot!

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Draw shapescript subshapes without color gradient
« Reply #6 on: December 15, 2020, 11:40:10 am »
Hi Takeshi-san,

Since, as Geert suggests, you are the "gradient fill sensei", do you have a solution for when you need to place a rectangle over the top of other EA generated glyphs as in:
Code: [Select]
decoration mydecoration //v1.0 13-Jul-2015
{
orientation="NE";
if(hasproperty("rectanglenotation","0"))
setorigin("NE",-40,5);
else
setorigin("NE",-20,5);
setpencolor(getuserfillcolor());
setfillcolor(getuserfillcolor());
rectangle(-10,-10,110,110);
}

shape main
{

layouttype="border";
noshadow=true;

//delete color setting for the tagged value to be simple
setfillcolor(getuserfillcolor());

//main shape
setFontColor(0,0,0);

if(hasproperty("rectanglenotation","0"))
{ //Icon Form
startPath();
setfixedregion(80,0,100,0);
moveto(0,0);
lineto(80,0);
lineto(100,50);
lineto(80,100);
setfixedregion(0,0,20,0);
lineto(0,100);
lineto(20,50);
lineto(0,0);
endPath();
fillandstrokePath();

addsubshape("padding","n");
addsubshape("name","center");
shape name
{
v_align="top";
h_align="center";
printwrapped("#name#");
}
shape padding
{
preferredheight=10;
}
}
else
{
drawnativeshape();
}
}

in this code, the oversize rectangle (in mydecoration) is to hide an underlying icon which we want to suppress.

What we want to happen is that this rectangle takes on the underlying gradient at that point.

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Takeshi K

  • EA User
  • **
  • Posts: 632
  • Karma: +43/-1
    • View Profile
    • Sparx Systems Japan
Re: Draw shapescript subshapes without color gradient
« Reply #7 on: December 15, 2020, 01:20:41 pm »
Hi Paolo,

Maybe I get what you mean, but I have no idea to satisfy your request in the ShapeScript.

But, the following option might help you.

Double-click the diagram background to open the properties dialog
-> move to the 'Elements' group
  -> uncheck the 'Use Stereotype Icons'

HTH,


--
t-kouno

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Draw shapescript subshapes without color gradient
« Reply #8 on: December 15, 2020, 03:48:25 pm »
Hi Paolo,

Maybe I get what you mean, but I have no idea to satisfy your request in the ShapeScript.

But, the following option might help you.

Double-click the diagram background to open the properties dialog
-> move to the 'Elements' group
  -> uncheck the 'Use Stereotype Icons'

HTH,
Thanks, Takeshi-san,

But, unfortunately, not all "icons" are icons (See UML Activity) and so do not respond to the [  ] Use Stereotype Icons setting.  EAUI, I'm afraid.
That's why we have to "overlay" them.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!