colorname

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 5.1, Creation date: 2022-01-30, Last change: 2025-09-15

returns a name for a color string or a cell list of colstrings



See Also: colofn , colofPose , nofcolmap

Example Illustration

 missing image of colorname(cs,num)

Syntax

cname=colorname(cs,[num])

Input Parameter

cs: color such such as 'r--', or {'r--','b.-'}
num: length of format; 0 is automatic

Output Parameter

cname: string or cell list of strings

Examples


colorname({'b--','y'},3)




Copyright 2022-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, colorname, is designed to return a name for a color string or a list of color strings. It is part of the SolidGeometry library and was introduced in version 5.1. The function takes two input parameters and returns a string or a cell list of strings as output.

Input Parameters

Output

Algorithm Details

The function begins by determining the value of num using the helper function getfuncparams. It then defines a lookup table, tab, which maps single-character color codes to their corresponding color names.

If cs is a scalar and numeric, it is converted to a color string using the colofn function.

If cs is a cell array, the function iterates over each element, recursively calling colorname for each color string. The results are stored in a cell array cname. The function then converts this cell array to a string using cell2str and updates cname with these string values.

If cs is not a cell array, the function checks if the first character of cs matches any entry in the first column of tab. If a match is found, cname is set to the corresponding color name from the second column of tab.

If num is specified and greater than 0, the function formats cname to the specified length using sprintf.

If no match is found in tab, cname is set to an empty array.

Example

Calling colorname({'b--','y'},3) will return a cell array with formatted color names for the input color strings.

Algorithm explaination created using ChatGPT on 2025-08-19 01:44. (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