title: Modelica web colors
body: <p>I thought it might be convenient to define some colors as constants to use later on in Modelica color annotations. As it seems the web colors are an accepted standard, I copied all of them into a package of constant arrays:</p>
  <ul>
  <li><a href="https://en.wikipedia.org/wiki/Web_colors" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Web_colors</a></li>
  <li><a href="https://gist.github.com/thorade/a1298571938231ef90d3bedf6b514967" rel="nofollow noreferrer">https://gist.github.com/thorade/a1298571938231ef90d3bedf6b514967</a></li>
  </ul>
  <p>But it seems I cannot use them as intended, the following example fails.
  It seems literals work, or if I define the constant in the same class, but not if I import it.
  Am I doing something wrong, or is it a limitation of the tool I am using?</p>
  <pre><code>within ;
  package Modelica_Colors
    type RealColor = Modelica.Icons.TypeReal[3] (each min=0, each max=255);
    package BasicColors
      final constant RealColor Aqua={0,255,255};
      final constant RealColor Black={0,0,0};
      final constant RealColor Blue={0,0,255};
      final constant RealColor Fuchsia={255,0,255};
      final constant RealColor Gray={128,128,128};
      final constant RealColor Grey={128,128,128};
      final constant RealColor Green={0,128,0};
      final constant RealColor Lime={0,255,0};
      final constant RealColor Maroon={128,0,0};
      final constant RealColor Navy={0,0,128};
      final constant RealColor Olive={128,128,0};
      final constant RealColor Purple={128,0,128};
      final constant RealColor Red={255,0,0};
      final constant RealColor Silver={192,192,192};
      final constant RealColor Teal={0,128,128};
      final constant RealColor White={255,255,255};
      final constant RealColor Yellow={255,255,0};
    end BasicColors;
  
    package Colors
      final constant RealColor Crimson={220,20,60};
      final constant RealColor Cyan={0,255,255};
      final constant RealColor DarkBlue={0,0,139};
      final constant RealColor DarkCyan={0,139,139};
      final constant RealColor OliveDrab={107,142,35};
      final constant RealColor Orange={255,165,0};
      final constant RealColor OrangeRed={255,69,0};
      final constant RealColor Orchid={218,112,214};
      final constant RealColor PaleGoldenRod={238,232,170};
      final constant RealColor PaleGreen={152,251,152};
      final constant RealColor Yellow={255,255,0};
      final constant RealColor YellowGreen={154,205,50};
    end Colors;
  
  model Test
    // works
    constant RealColor test_const1={255,20,147}; // pinkish
  
    // does not work
    final constant RealColor test_equal=Modelica_Colors.Colors.OrangeRed;
    constant RealColor test_pi={Modelica.Constants.pi,2*Modelica.Constants.pi,3*Modelica.Constants.pi};
    import Modelica_Colors.BasicColors.Yellow;
  
  protected 
    // works
    constant RealColor test_const2={147,20,255};
  
    annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
            Rectangle(
            extent={{-100,100},{0,0}},
            lineColor=test_const2,
            fillColor=test_const1,
            fillPattern=FillPattern.Solid),
            
            Rectangle(
            extent={{0,0},{100,-100}},
            lineColor=Modelica_Colors.Colors.Cyan,
            fillColor=Yellow,
            fillPattern=FillPattern.Solid),
            
            Rectangle(
            extent={{0,100},{100,0}},
            lineColor=test_equal,
            fillColor=test_equal,
            fillPattern=FillPattern.Solid),
            
            Rectangle(
            extent={{-100,0},{0,-100}},
            lineColor=test_equal,
            fillColor=test_pi,
            fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(
            preserveAspectRatio=false)));
  
  end Test;
  
    annotation (uses(Modelica(version=&quot;3.2.3&quot;)));
  end Modelica_Colors;
  </code></pre>