col2RGB

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 1.0, Creation date: 2012-06-08, Last change: 2025-09-14

generates a colorvector from the colorchar



See Also: SGshowcolors , color , VLcol , colofn

Example Illustration

 missing image of col2RGB(cm)

Syntax

RGB=col2RGB(cm)

Input Parameter

cm: color 0:7

Output Parameter

RGB: index to colormap VLcol

Examples


col2RGB(3)




Copyright 2012-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, col2RGB, is designed to convert a color index into an RGB color vector. It is part of the SG-Library and was created by Tim Lueth in 2012.

Input Parameters

Output Results

Algorithm Steps

  1. Check if cm is numeric. If not, convert it using the color function.
  2. Use a switch statement to map the color index cm to an RGB vector:
    • Case 7: RGB = [0.8 0.8 0.8] (light gray)
    • Case 6: RGB = [1.0 1.0 0.0] (yellow)
    • Case 5: RGB = [1.0 0.0 1.0] (magenta)
    • Case 4: RGB = [1.0 0.0 0.0] (red)
    • Case 3: RGB = [0.0 1.0 1.0] (cyan)
    • Case 2: RGB = [0.0 1.0 0.0] (green)
    • Case 1: RGB = [0.0 0.0 1.0] (blue)
    • Case 0: RGB = [0.2 0.2 0.2] (dark gray)
    • Otherwise: Generate a random RGB vector using rand(1,3).
  3. If no output argument is specified (nargout == 0), visualize the color:
    • Create a figure using SGfigure(-30,30).
    • Create a bar object A using SGbar.
    • Color the faces of A using SGcolorfaces(A,RGB).
    • Plot A with transparency using SGplotalpha(A).
Algorithm explaination created using ChatGPT on 2025-08-18 23:43. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21