SGcolorsample

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Samples
Introduced first in SolidGeometry 4.9, Creation date: 2020-08-20, Last change: 2025-08-19

creates boxes in colors with text

Description

This function is slow if it creates text, therefor it was extracted from SGsample
This function checks wether the color code is correct

See Also: SGsample

Example Illustration

 missing image of SGcolorsample()

Syntax

SG=SGcolorsample([])

Property names

'text' : if 'text' is used asl argument, the boxes show text descriptors

Output Parameter

SG: Colored Boxes

Examples


SGcolorsample
SGcolorsample('text')




Copyright 2020-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, SGcolorsample, generates colored boxes, optionally with text descriptors, using the SolidGeometry library. Below is a detailed explanation of the algorithm and its parameters.

Input Parameters

Algorithm Steps

  1. Check for 'text' Argument: The function uses getvarg to check if 'text' is included in varargin. This determines whether text descriptors will be added to the boxes.
  2. Initialize Box: A base box A is created using SGbox.
  3. Loop Through Colors: A loop runs from 1 to 8, each time selecting a color from the string 'kbgcrmyw' using colofn.
  4. Transform and Color Box: For each iteration, the box A is transformed using SGtransP to a new position along the x-axis (i*35, 0, 0).
  5. Apply Color: The transformed box is colored using SGcolorfaces with the selected color.
  6. Add Text (Optional): If 'text' is true, SGtextstamp is used to add a text descriptor to the box, indicating its color.
  7. Concatenate Boxes: The colored (and possibly labeled) box is concatenated to B using SGcat2.
  8. Output Result: The final set of boxes is assigned to SG.
  9. Plotting (Optional): If no output argument is specified, the function plots the boxes using SGfigure and SGplotalpha.

Output

This function is part of the SolidGeometry library and was introduced in version 4.9. It is designed to visually demonstrate color coding and optionally label each color for clarity.

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