Book a Demo

Author Topic: Connector ShapeScript to change line colour (including line ends)  (Read 4003 times)

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
We have he following connector ShapeScript to change the line colour based on a tag value. The script changes the colour of the line but not of the line ends - e.g., arrowheads.

What are we missing?

Code: [Select]
shape main
{
noShadow=true;
SetLineStyle("SOLID");

if(HasTag("Status","Live"))
{
SetPenColor(102,204,102);
}
else if(HasTag("Status","In Development"))
{
SetPenColor(0,0,255);
}
else if(HasTag("Status","Deprecated"))
{
SetPenColor(255,195,0);
}
else if(HasTag("Status","Decommissioned"))
{
SetPenColor(199,0,57);
}

MoveTo(0,0);
LineTo(100,0);
}

label middlebottomlabel
{
print("");
}
« Last Edit: February 03, 2022, 09:53:40 pm by Modesto Vega »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector ShapeScript to change line colour (including line ends)
« Reply #1 on: February 03, 2022, 09:59:45 pm »
Nothing. That's a bug. I did not report it but accepted it since it won't be fixed anyway :-/

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector ShapeScript to change line colour (including line ends)
« Reply #2 on: February 03, 2022, 10:13:01 pm »
You are missing shape source and shape target in your shapescript.
These define the line ends.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector ShapeScript to change line colour (including line ends)
« Reply #3 on: February 03, 2022, 10:34:35 pm »
You are missing shape source and shape target in your shapescript.
These define the line ends.

Geert
Well, they ignore the color as well. That's what I said about the bug...

q-

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: Connector ShapeScript to change line colour (including line ends)
« Reply #4 on: February 04, 2022, 12:45:36 am »
Actually, I think Geert is correct. The ShapeScript below renders both ends correctly (it is based largely in of Geert's archimate shapescripts.

Code: [Select]
shape main
{
noShadow=true;
SetLineStyle("SOLID");

if(HasTag("Status","Live"))
{
SetPenColor(102,204,102);
}
else if(HasTag("Status","In Development"))
{
SetPenColor(0,0,255);
}
else if(HasTag("Status","Deprecated"))
{
SetPenColor(255,195,0);
}
else if(HasTag("Status","Decommissioned"))
{
SetPenColor(199,0,57);
}

MoveTo(0,0);
LineTo(100,0);
}

shape source
{

if(HasTag("Status","Live"))
{
SetPenColor(102,204,102);
SetFillColor(102,204,102);
}
else if(HasTag("Status","In Development"))
{
SetPenColor(0,0,255);
SetFillColor(0,0,255);
}
else if(HasTag("Status","Deprecated"))
{
SetPenColor(255,195,0);
SetFillColor(255,195,0);
}
else if(HasTag("Status","Decommissioned"))
{
SetPenColor(199,0,57);
SetFillColor(199,0,57);
}

ellipse(-4,-4,4,4);
}

shape target
{
if(HasTag("Status","Live"))
{
SetPenColor(102,204,102);
SetFillColor(102,204,102);
}
else if(HasTag("Status","In Development"))
{
SetPenColor(0,0,255);
SetFillColor(0,0,255);
}
else if(HasTag("Status","Deprecated"))
{
SetPenColor(255,195,0);
SetFillColor(255,195,0);
}
else if(HasTag("Status","Decommissioned"))
{
SetPenColor(199,0,57);
SetFillColor(199,0,57);
}

startpath();
moveto(0,0);
lineto(10,4);
lineto(10,-4);
lineto(0,0);
endpath();
fillandstrokepath();
}

label middlebottomlabel
{
print("");
}
So I guess if I do
Code: [Select]
startpath();
moveto(0,0);
lineto(10,4);
lineto(10,-4);
endpath();
fillandstrokepath();
I will mange to render an open arrowhead of the right colour.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector ShapeScript to change line colour (including line ends)
« Reply #5 on: February 04, 2022, 02:59:36 am »
Well, if you fill  a path it will not be open but filled.

q.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: Connector ShapeScript to change line colour (including line ends)
« Reply #6 on: February 04, 2022, 03:12:34 am »
Well, if you fill  a path it will not be open but filled.

q.
Indeed, trying to see if strokepath() produces the desired result.