Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
within Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps;
function coolWarm "Returns the \"coolWarm\" color map"
extends Modelica.Mechanics.MultiBody.Interfaces.partialColorMap;

protected
final Real Start[3] = {59/255, 76/255, 192/255}; // blue
final Real Mid[3] = {242/255, 242/255, 242/255}; // gray
final Real End[3] = {180/255, 4/255, 38/255}; // red

final Real cm[n_colors,3];
final Real t; // normalized position
final Real u; // interpolation factor

algorithm
if n_colors >= 1 then
for i in 1:n_colors loop
t := (i-1)/(n_colors-1);

if t <= 0.5 then
u := t/0.5;
cm[i,:] := (1-u)*Start + u*Mid;
else
u := (t-0.5)/0.5;
cm[i,:] := (1-u)*Mid + u*End;
end if;
end for;

colorMap := 255*cm;
else
colorMap := [59,76,192];
end if;

annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
ColorMaps.<strong>coolWarm</strong>();
ColorMaps.<strong>coolWarm</strong>(n_colors=64);
</pre></blockquote>
<h4>Description</h4>
<p>
This function returns the color map \"coolWarm.\" A color map
is a Real[:,3] array where every row represents a color.
With the optional argument \"n_colors\" the number of rows
of the returned array can be defined. The default value is
\"n_colors=64\" (it is usually best if n_colors is a multiple of 4).
Image of the \"coolWarm\" color map:
</p>

<blockquote>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/coolWarm.png\">
</blockquote>

<h4>See also</h4>
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps\">ColorMaps</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.colorMapToSvg\">colorMapToSvg</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.scalarToColor\">scalarToColor</a>.
</html>"));
end coolWarm;
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ spring
summer
autumn
winter
coolWarm
trafficLight
plasma
viridis
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
within Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps;
function plasma "Returns the \"plasma\" color map"
extends .Modelica.Mechanics.MultiBody.Interfaces.partialColorMap;

protected
final Real Start[3] = {13/255, 8/255, 135/255};
final Real Mid[3] = {219/255, 92/255, 104};
final Real End[3] = {240/255, 249/255, 33/255};

final Real cm[n_colors,3];
final Real t; // normalized position
final Real u; // interpolation factor
algorithm
if n_colors >= 1 then
for i in 1:n_colors loop
t := (i-1)/(n_colors-1);

if t <= 0.5 then
u := t/0.5;
cm[i,:] := (1-u)*Start + u*Mid;
else
u := (t-0.5)/0.5;
cm[i,:] := (1-u)*Mid + u*End;
end if;
end for;

colorMap := 255*cm;
else
colorMap := [122,76,192];
end if;

annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
ColorMaps.<strong>plasma</strong>();
ColorMaps.<strong>plasma</strong>(n_colors=64);
</pre></blockquote>
<h4>Description</h4>
<p>
This function returns the color map \"plasma.\" A color map
is a Real[:,3] array where every row represents a color.
With the optional argument \"n_colors\" the number of rows
of the returned array can be defined. The default value is
\"n_colors=64\" (it is usually best if n_colors is a multiple of 4).
Image of the \"plasma\" color map:
</p>

<blockquote>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/plasma.png\">
</blockquote>

<h4>See also</h4>
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps\">ColorMaps</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.colorMapToSvg\">colorMapToSvg</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.scalarToColor\">scalarToColor</a>.
</html>"));
end plasma;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
within Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps;
function trafficLight "Returns the \"trafficLight\" color map"
extends Modelica.Mechanics.MultiBody.Interfaces.partialColorMap(n_colors=3);

protected
final Real Start[3] = {122/255, 255/255, 122/255}; // mid-green
final Real Mid[3] = {255/255, 230/255, 0}; // orange
final Real End[3] = {128/255, 0, 0}; // red

final Real cm[n_colors,3];
final Real t; // normalized position
final Real u; // interpolation factor
algorithm
if n_colors >= 1 then
for i in 1:n_colors loop
t := (i-1)/(n_colors-1);

if t <= 0.5 then
u := t/0.5;
cm[i,:] := (1-u)*Start + u*Mid;
else
u := (t-0.5)/0.5;
cm[i,:] := (1-u)*Mid + u*End;
end if;
end for;

colorMap := 255*cm;
else
colorMap := [122,76,192];
end if;

annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
ColorMaps.<strong>trafficLight</strong>();
ColorMaps.<strong>trafficLight</strong>(n_colors=3);
</pre></blockquote>
<h4>Description</h4>
<p>
This function returns the color map \"trafficLight.\" A color map
is a Real[:,3] array where every row represents a color.
With the optional argument \"n_colors\" the number of rows
of the returned array can be defined. The default value is
\"n_colors=3\".
Image of the \"trafficLight\" color map:
</p>

<blockquote>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/trafficLight.png\">
</blockquote>

<h4>See also</h4>
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps\">ColorMaps</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.colorMapToSvg\">colorMapToSvg</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.scalarToColor\">scalarToColor</a>.
</html>"));

end trafficLight;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
within Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps;
function viridis "Returns the \"viridis\" color map"
extends Modelica.Mechanics.MultiBody.Interfaces.partialColorMap;

protected
final Real Start[3] = {13/255, 8/255, 135/255};
final Real Mid[3] = {219/255, 92/255, 104};
final Real End[3] = {240/255, 249/255, 33/255};

final Real cm[n_colors,3];
final Real t; // normalized position
final Real u; // interpolation factor
algorithm
if n_colors >= 1 then
for i in 1:n_colors loop
t := (i-1)/(n_colors-1);

if t <= 0.5 then
u := t/0.5;
cm[i,:] := (1-u)*Start + u*Mid;
else
u := (t-0.5)/0.5;
cm[i,:] := (1-u)*Mid + u*End;
end if;
end for;

colorMap := 255*cm;
else
colorMap := [122,76,192];
end if;

annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
ColorMaps.<strong>viridis</strong>();
ColorMaps.<strong>viridis</strong>(n_colors=64);
</pre></blockquote>
<h4>Description</h4>
<p>
This function returns the color map \"viridis.\" A color map
is a Real[:,3] array where every row represents a color.
With the optional argument \"n_colors\" the number of rows
of the returned array can be defined. The default value is
\"n_colors=64\" (it is usually best if n_colors is a multiple of 4).
Image of the \"viridis\" color map:
</p>

<blockquote>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/viridis.png\">
</blockquote>

<h4>See also</h4>
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps\">ColorMaps</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.colorMapToSvg\">colorMapToSvg</a>,
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.scalarToColor\">scalarToColor</a>.
</html>"));
end viridis;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to regenerate all 11 color maps to have consistent font and color gradients?

Copy link
Author

@smathimech smathimech Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ColorMaps

Tried to re‑create or closely match all text styles, and the figure has been updated accordingly. If it look well, then it can be commited.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.