colofn

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 2.1, Creation date: 2015-01-05, Last change: 2025-09-14

returns a color char for a number 0..7

Description

simple auxiliary function for color use in for loops
for having a larger collection of colors use 'nofcolmap'

See Also: SGshowcolors , nofcolmap , color , VLcol , colofPose , plotannotatecolors

Example Illustration

 missing image of colofn(i,colbar,colstr)

Syntax

c=colofn(i,[colbar,colstr])

Input Parameter

i: integer number
colbar: order of colors; default is 'kbgcmyrw'
colstr: colorstring such as 'R*--'

Output Parameter

c: color char string

Examples


colofn(4)
colofn(4,'kymg')
colofn(4,'kymg','r--')
colofn(4,'kymg','--')




Copyright 2015-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, colofn, is an auxiliary procedure designed to return a color character for a given integer input. It is part of the SolidGeometry library and was introduced to provide a simple way to handle colors in loops.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize colbar to 'kbgcmyrw' unless a different order is provided as the second argument.
  2. Initialize colstr to an empty string unless a specific color string is provided as the third argument.
  3. Calculate the length of colbar and store it in n.
  4. Use the mod1 function to determine the index i within the bounds of colbar.
  5. Select the color character from colbar using the calculated index i.
  6. If colstr is not empty, replace its first character with the selected color character and assign it to c.
  7. If no output is expected (nargout==0), create a figure and plot using the selected color.

Example Usage

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