Syntax
SGshowcolors([n,c])
Input Parameter
Examples
SGshowcolors (2)
SGshowcolors (3)
SGshowcolors (4)
Copyright 2018-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, SGshowcolors
, is designed to display a grid of colors to help understand how to set RGB values. It is part of the SolidGeometry library and was introduced in version 4.4.
Input Parameters
- n: This parameter determines the number of colors to display. The total number of colors is calculated as
n^3
. The value of n
must be greater than 2.
Algorithm Steps
- The function begins by retrieving the input parameter
n
using getfuncparams
. If n
is not provided, it defaults to 2.
- The value of
n
is floored to ensure it is an integer.
- The total number of colors,
nn
, is calculated as n^3
.
- A matrix
x
is initialized to store RGB values for each color. The matrix has dimensions nn x 3
.
- If the second parameter
c
is not provided, it is set to the ceiling of the square root of nn
.
- The number of rows
r
is calculated as the ceiling of nn/c
.
- A nested loop iterates over the range of
n
for each RGB component (i, k, l). For each combination, an RGB value is calculated and stored in x
.
- A new figure is created using
SGfigure
.
- A loop iterates over each color index
i
from 1 to nn
:
- A subplot is created for each color with dimensions
r x c
.
- The color limits are set to [0, 1].
- The title of each subplot displays the RGB values scaled by
(n-1)
.
- The background color of each subplot is set to the corresponding RGB value from
x
.
- The X and Y axes are made invisible.
- The function ends by calling
shg
to bring the figure window to the front.
Algorithm explaination created using ChatGPT on 2025-08-19 01:09. (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