-
Notifications
You must be signed in to change notification settings - Fork 182
Add four Visualizer colormap function and png files #4737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smathimech
wants to merge
6
commits into
modelica:master
Choose a base branch
from
smathimech:colormap_#4689
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+234
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0cb00f
Added four Visualizer colormap function and png files
smathimech 0dea92c
Comparison of different colormap.png
smathimech 74308dd
renamed function names, updated string descriptions
smathimech f1e4528
updated colomap figure
smathimech b83aefb
Fix naming
beutlich c4bf80a
Document update for traficLight fun
smathimech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
Modelica/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/coolWarm.mo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,7 @@ spring | |
| summer | ||
| autumn | ||
| winter | ||
| coolWarm | ||
| trafficLight | ||
| plasma | ||
| viridis | ||
57 changes: 57 additions & 0 deletions
57
Modelica/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/plasma.mo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
58 changes: 58 additions & 0 deletions
58
Modelica/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/trafficLight.mo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
57 changes: 57 additions & 0 deletions
57
Modelica/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/viridis.mo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Binary file modified
BIN
+51.3 KB
(720%)
...Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/ColorMaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.35 KB
.../Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/coolWarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.34 KB
...ca/Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/plasma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.25 KB
...ources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/trafficLight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.33 KB
...a/Resources/Images/Mechanics/MultiBody/Visualizers/Colors/ColorMaps/viridis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.